Skip to content

With EnsureSemantics on, Buttons Maintain Focus State on Press #158527

Closed

Description

@emma-roudabush-disney

Steps to reproduce

On flutter beta version 3.27.0-0.1.pre

  1. Turn on semantics auto rendering for application
  2. Have an app with a button that doesn't result in navigation
  3. Launch on web
  4. Press button

Expected results

Focus state and visual should only be showing on keyboard navigation (i.e. tab)

Actual results

If you press a button/interactive component (that doesn't navigate), after release, the button will both have focus and show focus visual. If autorendering of semantics is disabled, then this issue doesn't happen.

Code sample

With favorites sample

Code sample
  Widget build(BuildContext context) {
    SemanticsBinding.instance.ensureSemantics();
    return ChangeNotifierProvider<Favorites>(
      create: (context) => Favorites(),
      child: MaterialApp.router(
        title: 'Testing Sample',
        theme: ThemeData(
          colorSchemeSeed: Colors.blue,
          visualDensity: VisualDensity.adaptivePlatformDensity,
        ),
        routerConfig: router(),
      ),
    );
  }

Screenshots or Video

Screenshots / Video demonstration
Screen.Recording.2024-11-12.at.12.21.49.PM.mov

Logs

No response

Flutter Doctor output

Doctor output
Flutter 3.27.0-0.1.pre • channel beta •
https://emma-roudabush-disney:[email protected]
/flutter/flutter.git
Framework • revision 2e2c358c9b (3 weeks ago) • 2024-10-22 11:02:13 -0400
Engine • revision af0f0d559c
Tools • Dart 3.6.0 (build 3.6.0-334.3.beta) • DevTools 2.40.1
emmaroudabush@V17CNW73XQ sandbox % flutter doctor -v
[!] Flutter (Channel beta, 3.27.0-0.1.pre, on macOS 14.5 23F79 darwin-arm64,
    locale en-US)
    • Flutter version 3.27.0-0.1.pre on channel beta at
      /Users/emmaroudabush/Source/flutter
    ! Upstream repository
      https://emma-roudabush-disney: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@gith
      ub.com/flutter/flutter.git is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to
      https://emma-roudabush-disney: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@gith
      ub.com/flutter/flutter.git to dismiss this error.
    • Framework revision 2e2c358c9b (3 weeks ago), 2024-10-22 11:02:13 -0400
    • Engine revision af0f0d559c
    • Dart version 3.6.0 (build 3.6.0-334.3.beta)
    • DevTools version 2.40.1
    • If those were intentional, you can disregard the above warnings; however it
      is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version
    32.1.0-rc1)
    • Android SDK at /Users/emmaroudabush/Library/Android/sdk
    • Platform android-34, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Users/emmaroudabush/Downloads/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.95.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.100.0

Activity

  1. darshankawar commented on Nov 13, 2024

    @darshankawar
    Member

    Thanks for the report. I was able to replicate this only on web platform using latest beta and master versions. The reported behavior doesn't occur on latest stable and on other platforms.

    Screenshot 2024-11-13 at 12 43 40 PM

    Code sample : https://github.com/flutter/codelabs/tree/main/testing_codelab/step_04 and adding SemanticsBinding.instance.ensureSemantics(); as mentioned in original description.

    stable : 3.24.4
    master : 3.27.0-1.0.pre.471
    beta : 3.27.0-0.1.pre
    
  2. added
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    platform-webWeb applications specifically
    c: regressionIt was better in the past than it is now
    team-webOwned by Web platform team
    frameworkflutter/packages/flutter repository. See also f: labels.
    and removed
    in triagePresently being triaged by the triage team
    on Nov 13, 2024
  3. added
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    P2Important issues not at the top of the work list
    triaged-webTriaged by Web platform team
    on Nov 19, 2024
  4. yjbanov commented on Dec 17, 2024

    @yjbanov
    Contributor

    I can reproduce the behavior. However, I think the bug is the exact opposite of what we think. The behavior of moving the keyboard focus to the clicked widget is the idiomatic web behavior. This is enabled by SemanticsBinding.instance.ensureSemantics() because the focus is linked to the HTML DOM, allowing the browser to dictate where the focus goes. The bug is in the framework in the case when semantics is disabled. On the web the framework should move the focus on click, but currently it doesn't.

    The other behavior, that I'm observing both with semantics enabled and disabled, is when you click outside the focused widget onto something that's not focusable. The idiomatic behavior on the web is that the widget should be blurred. This should be fixed in the framework too.

  5. 13 remaining items

  6. added
    P0Critical issues such as a build break or regression
    and removed
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    P2Important issues not at the top of the work list
    on Jan 24, 2025
  7. kevmoo commented on Jan 29, 2025

    @kevmoo
    Contributor

    Bumping to P0. This is a regression. CC @zanderso

  8. added
    P1High-priority issues at the top of the work list
    and removed
    P0Critical issues such as a build break or regression
    on Jan 29, 2025
  9. yjbanov commented on Jan 29, 2025

    @yjbanov
    Contributor

    P0 means the world is on fire. This is P1.

  10. kevmoo commented on Feb 4, 2025

    @kevmoo
    Contributor

    The PR fixing this is now unblocked!

  11. added
    r: fixedIssue is closed as already fixed in a newer version
    on Feb 7, 2025
  12. github-actions commented on Feb 21, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  13. locked as resolved and limited conversation to collaborators on Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: regressionIt was better in the past than it is nowcustomer: castawayfound in release: 3.27Found to occur in 3.27frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions