Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[web] generalize focusability in semantics#41831

Merged
auto-submit[bot] merged 3 commits into
flutter-team-archive:mainfrom
yjbanov:a11y-focusables
May 10, 2023
Merged

[web] generalize focusability in semantics#41831
auto-submit[bot] merged 3 commits into
flutter-team-archive:mainfrom
yjbanov:a11y-focusables

Conversation

@yjbanov

@yjbanov yjbanov commented May 8, 2023

Copy link
Copy Markdown
Contributor

Introduce 2 new classes for a11y focus management:

  • AccessibilityFocusManager: a generic class that attaches "focus" and "blur" event handlers, and forwards the events to the framework as SemanticsAction.didGainAccessibilityFocus and SemanticsAction.didLoseAccessibilityFocus respectively. Provides the changeFocus method for the framework to move a11y focus to the target element.
  • Focusable: a role manager that provides generic focus management functionality to SemanticsObjects that don't need anything special.

Rewrites focus management using the above two classes as follows:

  • All focusable nodes except text fields and incrementables get the Focusable role (all custom focus stuff in Tappable was removed and delegated to Focusable).
  • Incrementable uses a custom <input> internally and so it cannot use the Focusable role. Instead, it uses AccessibilityFocusManager to manage the focus on the <input> element.

Behavioral changes:

  • Fixes [Web] Setting autofocus on checkbox doesn't have an effect in accessibility mode flutter/flutter#118737, but more generally fixes all nodes that use the isFocusable and hasFocus bits.
  • Tappable only partially implemented focusability (e.g. it didn't generate the respective SemanticsAction events). Now by delegating to Focusable, it will inherit all the functionality.
  • Incrementable and Checkable (checkboxes, radios, switches) get focus management features for the first time.
  • Elements that are not inherently focusable (text, images) can now be focused if semantics requires them to be.
  • TextField is left alone for now as focus and on-screen keyboard interact with each other in non-obvious ways.

@flutter-dashboard flutter-dashboard Bot added the platform-web Code specifically for the web engine label May 8, 2023
@yjbanov yjbanov marked this pull request as ready for review May 8, 2023 23:49
@yjbanov yjbanov force-pushed the a11y-focusables branch from ed2a8e5 to 08a128e Compare May 9, 2023 00:03
Comment thread lib/web_ui/lib/src/engine/semantics/focusable.dart Outdated
Comment thread lib/web_ui/lib/src/engine/semantics/focusable.dart
@yjbanov yjbanov force-pushed the a11y-focusables branch from 08a128e to 5ef5fad Compare May 10, 2023 17:47
@yjbanov yjbanov force-pushed the a11y-focusables branch from 9c2a564 to da5c550 Compare May 10, 2023 21:43
@yjbanov yjbanov added the autosubmit Merge PR when tree becomes green via auto submit App label May 10, 2023
@auto-submit auto-submit Bot merged commit 7ad6470 into flutter-team-archive:main May 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 10, 2023
auto-submit Bot pushed a commit to flutter/flutter that referenced this pull request May 11, 2023
flutter-team-archive/engine@de6e130...ef771f9

2023-05-10 chris@bracken.jp [macos] Disable background colour tests (flutter-team-archive/engine#41904)
2023-05-10 yjbanov@google.com [web] generalize focusability in semantics (flutter-team-archive/engine#41831)
2023-05-10 skia-flutter-autoroll@skia.org Roll Skia from 32f4cfc2460b to 1a29bd9a0147 (12 revisions) (flutter-team-archive/engine#41905)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC aaclarke@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
CaseyHillers pushed a commit to CaseyHillers/flutter that referenced this pull request May 24, 2023
…6481)

flutter-team-archive/engine@de6e130...ef771f9

2023-05-10 chris@bracken.jp [macos] Disable background colour tests (flutter-team-archive/engine#41904)
2023-05-10 yjbanov@google.com [web] generalize focusability in semantics (flutter-team-archive/engine#41831)
2023-05-10 skia-flutter-autoroll@skia.org Roll Skia from 32f4cfc2460b to 1a29bd9a0147 (12 revisions) (flutter-team-archive/engine#41905)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC aaclarke@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

accessibility autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine

Development

Successfully merging this pull request may close these issues.

[Web] Setting autofocus on checkbox doesn't have an effect in accessibility mode

3 participants