Repository navigation
feat(web): Add navigation focus handler for assistive technology focus restoration - #170046
Conversation
|
Difference between TAB navigation and VoiceOver navigation: Using Tab + Space (keyboard-only user): Press Tab to focus on the "Go to page two" button in https://focus-demo-0529-before.web.app/ Press Space to activate it On Page Two, press Tab to focus on the "Back to page one" button Press Space to activate it Back on Page One, the focus is restored to the "Go to page two" button (correct behavior for keyboard users) Because DOM focus was used, and frameworks like Flutter handle focus restoration for keyboard users Using VoiceOver on macOS: Use Control + Option + Right Arrow to navigate to the "Go to page two" button Use Control + Option + Space to activate it On Page Two, use Control + Option + Right Arrow to focus on the "Back to page one" button Activate it Back on Page One, VoiceOver virtual cursor lands on the "Page one" heading, not the "Go to page two" button Because VoiceOver’s virtual cursor is separate from DOM focus, and it doesn’t trigger or track DOM focus events by default |
@yjbanov , @mdebbar, @hannah-hyj , From above observation, we can conclude that we need to forces DOM focus on the activated elements when using screen reader activations. Hence this PR can fix the issue #140483. |
|
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…s restoration (flutter#170046) **Description** This pull request adds a navigation focus handler to the Flutter web engine that bridges assistive technology activations with Flutter's focus tracking system. The listener intercepts screen reader activations (VoiceOver, NVDA, JAWS, etc.) and forces DOM focus on the activated elements, ensuring they integrate properly with Flutter's navigation focus restoration. **Before** When using VoiceOver or other screen readers to navigate between pages in a Flutter web app, focus restoration would fail because assistive technology activations don't naturally trigger the DOM focus events that Flutter's navigation system expects. Users would lose their navigation context, with focus jumping to default elements instead of returning to the previously activated button. **Before behavior demo** https://focus-demo-0529-before.web.app On mac os, Use command + F5 to activate voice over. Use control + option + arrow right to focus on "Go to page two" button. Use control + option + space to click the "Go to page two" button. Then in page two, use control + option + arrow right to focus on "Back to page one" button. The focus will be on "Page one" heading instead of "Go to page two" button. This is not expected **After** Screen reader users can now navigate between pages and have their focus properly restored to the previously activated element (e.g., "Go to Page Two" button) when returning to a previous page, providing a consistent and accessible navigation experience across all assistive technologies. **After behavior demo** https://focus-demo-0529-after.web.app On mac os, Use command + F5 to activate voice over. Use control + option + arrow right to focus on "Go to page two" button. Use control + option + space to click the "Go to page two" button. Then in page two, use control + option + arrow right to focus on "Back to page one" button. The focus will be on "Go to page two" button. This is expected. **Issue Fixed** This PR addresses GitHub Issue flutter#140483, which reports that VoiceOver focus restoration doesn't work in Flutter web applications during navigation. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…ogy focus restoration (flutter/flutter#170046)
…s restoration (flutter#170046) **Description** This pull request adds a navigation focus handler to the Flutter web engine that bridges assistive technology activations with Flutter's focus tracking system. The listener intercepts screen reader activations (VoiceOver, NVDA, JAWS, etc.) and forces DOM focus on the activated elements, ensuring they integrate properly with Flutter's navigation focus restoration. **Before** When using VoiceOver or other screen readers to navigate between pages in a Flutter web app, focus restoration would fail because assistive technology activations don't naturally trigger the DOM focus events that Flutter's navigation system expects. Users would lose their navigation context, with focus jumping to default elements instead of returning to the previously activated button. **Before behavior demo** https://focus-demo-0529-before.web.app On mac os, Use command + F5 to activate voice over. Use control + option + arrow right to focus on "Go to page two" button. Use control + option + space to click the "Go to page two" button. Then in page two, use control + option + arrow right to focus on "Back to page one" button. The focus will be on "Page one" heading instead of "Go to page two" button. This is not expected **After** Screen reader users can now navigate between pages and have their focus properly restored to the previously activated element (e.g., "Go to Page Two" button) when returning to a previous page, providing a consistent and accessible navigation experience across all assistive technologies. **After behavior demo** https://focus-demo-0529-after.web.app On mac os, Use command + F5 to activate voice over. Use control + option + arrow right to focus on "Go to page two" button. Use control + option + space to click the "Go to page two" button. Then in page two, use control + option + arrow right to focus on "Back to page one" button. The focus will be on "Go to page two" button. This is expected. **Issue Fixed** This PR addresses GitHub Issue flutter#140483, which reports that VoiceOver focus restoration doesn't work in Flutter web applications during navigation. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
Description
This pull request adds a navigation focus handler to the Flutter web engine that bridges assistive technology activations with Flutter's focus tracking system. The listener intercepts screen reader activations (VoiceOver, NVDA, JAWS, etc.) and forces DOM focus on the activated elements, ensuring they integrate properly with Flutter's navigation focus restoration.
Before
When using VoiceOver or other screen readers to navigate between pages in a Flutter web app, focus restoration would fail because assistive technology activations don't naturally trigger the DOM focus events that Flutter's navigation system expects. Users would lose their navigation context, with focus jumping to default elements instead of returning to the previously activated button.
Before behavior demo
https://focus-demo-0529-before.web.app
On mac os, Use command + F5 to activate voice over.
Use control + option + arrow right to focus on "Go to page two" button.
Use control + option + space to click the "Go to page two" button.
Then in page two, use control + option + arrow right to focus on "Back to page one" button.
The focus will be on "Page one" heading instead of "Go to page two" button. This is not expected
After
Screen reader users can now navigate between pages and have their focus properly restored to the previously activated element (e.g., "Go to Page Two" button) when returning to a previous page, providing a consistent and accessible navigation experience across all assistive technologies.
After behavior demo
https://focus-demo-0529-after.web.app
On mac os, Use command + F5 to activate voice over.
Use control + option + arrow right to focus on "Go to page two" button.
Use control + option + space to click the "Go to page two" button.
Then in page two, use control + option + arrow right to focus on "Back to page one" button.
The focus will be on "Go to page two" button. This is expected.
Issue Fixed
This PR addresses GitHub Issue #140483, which reports that VoiceOver focus restoration doesn't work in Flutter web applications during navigation.
Pre-launch Checklist
///).