-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Add blockAccessibilityFocus flag #175551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add blockAccessibilityFocus flag #175551
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new isA11yFocusable flag to SemanticsFlags to control accessibility focus. The changes span across Dart UI, web UI, and native engine code for Android and the embedder API. My review has identified a critical syntax error in packages/flutter/lib/src/semantics/semantics.dart that needs to be fixed. Additionally, for the feature to work on Android, corresponding changes are required in AccessibilityBridge.java to recognize the new semantics flags, which appear to be missing from this PR.
...tter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.cc
Outdated
Show resolved
Hide resolved
|
still a draft |
5e12540 to
ae247d3
Compare
|
@hannah-hyj FYI it still says "draft" in the title of this PR, if it is indeed no longer a draft. |
ae247d3 to
9850963
Compare
| int isExpanded, | ||
| int isRequired, | ||
| int isFocused, | ||
| int isA11yFocusable, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
our style guide suggest avoid abbreviation. we should use the full name isAccessibilityFocusable
9850963 to
e6e8bf2
Compare
b5a4b80 to
d639683
Compare
| bool hasRepeatedFlags(SemanticsFlags other) { | ||
| // isAccessibilityFocusBlocked is not checked in `hasRepeatedFlags` because | ||
| // two semantics nodes both with `isAccessibilityFocusBlocked` set to true is | ||
| // still compatible and not conflicting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, the method name no longer correct. Consider rename to something more descriptive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be renamed to hasConflictingFlags, but it will be a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should create a new method and deprecate this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will add a breaking change doc
| if (_flags.hasRepeatedFlags(other._flags)) { | ||
| return false; | ||
| } | ||
| if (_flags.isAccessibilityFocusBlocked != other._flags.isAccessibilityFocusBlocked) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if one is BlockSubTree another one is BlockCurrent, I think they can merge to be BlockSubTree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and in this case we would need to implement absorb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added to the absorb
chunhtai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| blockNode; | ||
|
|
||
| /// The AccessiblityFocusBlockType when two node get merged. | ||
| AccessiblityFocusBlockType merge(AccessiblityFocusBlockType other) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be private?
Roll Flutter from 027f2e4 to e5d5c01 (73 revisions) flutter/flutter@027f2e4...e5d5c01 2025-11-04 mdebbar@google.com [web] Upgrade Chrome to 141 (for engine tests) (flutter/flutter#177743) 2025-11-04 116356835+AbdeMohlbi@users.noreply.github.com Replace deprecated withOpacity in `chip_animation_style.0.dart` example (flutter/flutter#177834) 2025-11-04 engine-flutter-autoroll@skia.org Roll Skia from 03612114a36d to c89b6118266b (1 revision) (flutter/flutter#177991) 2025-11-04 mdebbar@google.com [web] Delete unused futurize util (flutter/flutter#177861) 2025-11-04 engine-flutter-autoroll@skia.org Roll Skia from 1a179581af75 to 03612114a36d (1 revision) (flutter/flutter#177984) 2025-11-04 engine-flutter-autoroll@skia.org Roll Skia from 150f844e83fb to 1a179581af75 (3 revisions) (flutter/flutter#177979) 2025-11-04 engine-flutter-autoroll@skia.org Roll Dart SDK from 6f1bd8d05b1d to 156bf665dba4 (2 revisions) (flutter/flutter#177976) 2025-11-04 engine-flutter-autoroll@skia.org Roll Skia from 3990fc40acdf to 150f844e83fb (1 revision) (flutter/flutter#177964) 2025-11-04 engine-flutter-autoroll@skia.org Roll Skia from 85adfd3b8e75 to 3990fc40acdf (1 revision) (flutter/flutter#177962) 2025-11-04 34871572+gmackall@users.noreply.github.com Fix `isHeif` crash (flutter/flutter#177944) 2025-11-04 engine-flutter-autoroll@skia.org Roll Dart SDK from ac065fcd782e to 6f1bd8d05b1d (1 revision) (flutter/flutter#177955) 2025-11-04 engine-flutter-autoroll@skia.org Roll Skia from 001516d132f0 to 85adfd3b8e75 (4 revisions) (flutter/flutter#177958) 2025-11-04 bkonyi@google.com [ Widget Preview ] Add analytic event that's reported when the previewer is opened (flutter/flutter#177949) 2025-11-04 fluttergithubbot@gmail.com Marks Linux_pixel_7pro dynamic_path_stroke_tessellation_perf__timeline_summary to be unflaky (flutter/flutter#171144) 2025-11-03 engine-flutter-autoroll@skia.org Roll Skia from da9b8fb01101 to 001516d132f0 (6 revisions) (flutter/flutter#177951) 2025-11-03 97480502+b-luk@users.noreply.github.com Add FAQ entry about our attempts to remove Skia image codecs. (flutter/flutter#177947) 2025-11-03 jhy03261997@gmail.com Add blockAccessibilityFocus flag (flutter/flutter#175551) 2025-11-03 ahmedsameha1@gmail.com Make sure that a SnackBarAction doesn't crash in 0x0 environment (flutter/flutter#177899) 2025-11-03 ahmedsameha1@gmail.com Make sure that a SelectionArea doesn't crash in 0x0 environment (flutter/flutter#177876) 2025-11-03 34871572+gmackall@users.noreply.github.com Speculative fix for android_verified_input_test (flutter/flutter#177937) 2025-11-03 kjlubick@users.noreply.github.com [skia] Explicitly disable XPS backend (flutter/flutter#177050) 2025-11-03 engine-flutter-autoroll@skia.org Roll Dart SDK from 2d3aa1d5cb9f to ac065fcd782e (2 revisions) (flutter/flutter#177927) 2025-11-03 737941+loic-sharma@users.noreply.github.com Improve Impeller's docs in the top-level docs folder (flutter/flutter#177848) 2025-11-03 ahmedsameha1@gmail.com Make sure that GridTile doesn't crash in 0x0 environment (flutter/flutter#175321) 2025-11-03 ahmedsameha1@gmail.com Make sure that a Slider doesn't crash in 0x0 environment (flutter/flutter#177882) 2025-11-03 planetmarshall@users.noreply.github.com fix(impeller): fix params to glDiscardFrameBufferEXT (flutter/flutter#175589) 2025-11-03 engine-flutter-autoroll@skia.org Roll Skia from 56a10bf56ee0 to da9b8fb01101 (5 revisions) (flutter/flutter#177928) 2025-11-03 47866232+chunhtai@users.noreply.github.com wires up set application locale to web engine (flutter/flutter#177284) 2025-11-03 jesswon@google.com [Android 16] Update `linux_android_emu_unstable` to use avd rev 7 (flutter/flutter#177854) 2025-11-03 ahmedsameha1@gmail.com Make sure that a CheckedPopupMenuItem doesn't crash in 0x0 environment (flutter/flutter#177545) 2025-11-03 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from Ynp3qiXocK8WLTjlb... to vxK5obzfr1X9P2kSh... (flutter/flutter#177917) 2025-11-03 130006795+Spivak-adam@users.noreply.github.com Update pubspec.yaml.tmpl build version tracker on line 5 (flutter/flutter#173600) 2025-11-03 jason-simmons@users.noreply.github.com [Impeller] Fix the source rectangle used when rendering an AtlasContents with the strict mode for nine-patch images (flutter/flutter#177860) 2025-11-03 git@reb0.org docs: Default Splash / Loading screen for web app in index.html (flutter/flutter#177084) 2025-11-03 engine-flutter-autoroll@skia.org Roll Skia from 25e1e4e96980 to 56a10bf56ee0 (6 revisions) (flutter/flutter#177910) 2025-11-03 ahmedsameha1@gmail.com Make sure that a PopupMenuItem doesn't crash in 0x0 environment (flutter/flutter#177533) 2025-11-03 ahmedsameha1@gmail.com Make sure that a RefreshProgressIndicator doesn't crash in 0x0 enviro… (flutter/flutter#177556) 2025-11-03 ahmedsameha1@gmail.com Make sure that a PopupMenuButton doesn't crash in 0x0 environment (flutter/flutter#177493) 2025-11-03 ahmedsameha1@gmail.com Make sure that a CircularProgressIndicator doesn't crash in 0x0 envir… (flutter/flutter#177555) 2025-11-02 ahmedsameha1@gmail.com Make sure that a Radio doesn't crash in 0x0 environment (flutter/flutter#177580) 2025-11-02 ahmedsameha1@gmail.com Make sure that a RadioListTile doesn't crash in 0x0 environment (flutter/flutter#177576) 2025-11-02 ahmedsameha1@gmail.com Make sure that an ExpandIcon doesn't crash in 0x0 envrionment (flutter/flutter#175042) 2025-11-02 ahmedsameha1@gmail.com Make sure that a RangeSlider doesn't crash in 0x0 environment (flutter/flutter#177642) 2025-11-02 ahmedsameha1@gmail.com Make sure that a GridTileBar doesn't crash in 0x0 environment (flutter/flutter#177546) 2025-11-02 ahmedsameha1@gmail.com Make sure that a LinearProgressIndicator doesn't crash in 0x0 environ… (flutter/flutter#177553) 2025-11-02 ahmedsameha1@gmail.com Make sure that a PopupMenuDivider doesn't crash in 0x0 environment (flutter/flutter#177445) ...
Add a new flag for a11y focusable - Accessibility focus, which is the focus used by screen readers like TalkBack and VoiceOver, is different from input focus. - Our current logic use some existing flags to decide if a node is accessibilty focusable. like "if it's a slider / has a check state / has keyboard focus/..., then it's a11y focusable" https://github.com/flutter/flutter/blob/ecbb115ae3a8cba2977ecab9f52086df860cfb1a/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java#L98 - but we lack the ability to explicitly set a node to be unfocusable in a11y! - This flag can be used to explicitly set some semantics nodes to be unfocusable in a11y mode. if it is false, we fall back to the logic "if it's a slider / has a check state / has keyboard focus/..., then it's a11y focusable" future use case 1: user can set live region to be not focusable, so when content changes, it will still announce, but the content can't be focused by swiping. future use case 2: when pushing a new route like a dialog, setting the semantics nodes in old pages to be un focusable. ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Add a new flag for a11y focusable - Accessibility focus, which is the focus used by screen readers like TalkBack and VoiceOver, is different from input focus. - Our current logic use some existing flags to decide if a node is accessibilty focusable. like "if it's a slider / has a check state / has keyboard focus/..., then it's a11y focusable" https://github.com/flutter/flutter/blob/ecbb115ae3a8cba2977ecab9f52086df860cfb1a/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java#L98 - but we lack the ability to explicitly set a node to be unfocusable in a11y! - This flag can be used to explicitly set some semantics nodes to be unfocusable in a11y mode. if it is false, we fall back to the logic "if it's a slider / has a check state / has keyboard focus/..., then it's a11y focusable" future use case 1: user can set live region to be not focusable, so when content changes, it will still announce, but the content can't be focused by swiping. future use case 2: when pushing a new route like a dialog, setting the semantics nodes in old pages to be un focusable. ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Add a new flag for a11y focusable
flutter/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java
Line 98 in ecbb115
future use case 1:
user can set live region to be not focusable, so when content changes, it will still announce, but the content can't be focused by swiping.
future use case 2:
when pushing a new route like a dialog, setting the semantics nodes in old pages to be un focusable.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.