zhongliugo bb784b983b
feat(web): Add navigation focus handler for assistive technology focus restoration (#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 #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.
2025-06-30 22:20:26 +00:00
..