Repository navigation
Commit e872aea
authored
[go_router] Keep web autocomplete focused in shell routes (flutter#13348)
## Summary
Fixes flutter/flutter#194873. Opening an `Autocomplete` overlay inside a
`ShellRoute` can add a semantics parent above the focused field. On
Flutter web, that detaches the field's DOM input and drops focus.
```diff
ShellRoute navigator semantics
- Semantics(container: true, child: navigator)
+ Semantics(container: true, explicitChildNodes: true, child: navigator)
```
The change keeps the field's semantics ancestry stable while retaining
the shell navigator boundary added to preserve shell chrome semantics.
It includes a regression test and a pending patch changelog entry for
the batched release workflow.
## Evidence
- **Before:** The regression test fails on unmodified `main`: the
focused field's semantics ancestor IDs change from `[6, 4, 3, 2, 1, 0]`
to `[6, 4, 7, 3, 2, 1, 0]` when options open. In a Chrome release web
repro with published `go_router` 18.1.1, typing `t`, `e`, `x` leaves the
field empty and browser focus leaves the input.
- **After:** The regression test passes. In the same Chrome repro with
the patched package, the field retains browser focus and contains `tex`;
shell navigation remains in the semantics tree.
- **Checks:** `format`, `analyze`, `dart-test`, `validate`, and
`publish-check` through `flutter_plugin_tools` pass for `go_router`. The
package and example tests pass.
## Merge Danger
**Door:** Two-way. The patch can be reverted without data migration.
**Blast Radius:** ShellRoute semantics trees. Explicit child nodes can
affect accessibility traversal and announcements for routed content;
existing shell chrome semantics tests and the new overlay regression
test pass. Human review should include accessibility behavior on
supported platforms.
## Pre-Review Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] page, which explains my
responsibilities.
- [x] I read and followed the [relevant style guides] and ran [the
auto-formatter].
- [x] I signed the [CLA].
- [x] The title of the PR starts with the name of the package surrounded
by square brackets, e.g. `[shared_preferences]`
- [x] I [linked to at least one issue that this PR fixes] in the
description above.
- [x] I followed [the version and CHANGELOG instructions], using
[semantic versioning] and the [repository CHANGELOG style], or I have
commented below to indicate which documented exception this PR falls
under[^1].
- [ ] I updated/added any relevant documentation (doc comments with
`///`).
- [x] I added new tests to check the change I am making, or I have
commented below to indicate which [test exemption] this PR falls
under[^1].
- [x] All existing and new tests are passing.
No public API or doc comments changed; the bug fix does not introduce a
new API. `go_router` uses pending changelog files for batched releases;
this PR adds a patch entry there. This PR was prepared with AI
assistance and reviewed by the contributor.
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.
[^1]: Regular contributors who have demonstrated familiarity with the
repository guidelines only need to comment if the PR is not
auto-exempted by repo tooling.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/packages/blob/main/CONTRIBUTING.md
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md
[relevant style guides]:
https://github.com/flutter/packages/blob/main/CONTRIBUTING.md#style
[the auto-formatter]:
https://github.com/flutter/packages/blob/main/script/tool/README.md#format-code
[CLA]: https://cla.developers.google.com/
[Discord]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
[linked to at least one issue that this PR fixes]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview
[the version and CHANGELOG instructions]:
https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#version-and-changelog-updates
[semantic versioning]:
https://dart.dev/tools/pub/versioning#semantic-versions
[repository CHANGELOG style]:
https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changelog-style
[test exemption]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests1 parent ea7e031 commit e872aea
3 files changed
Lines changed: 82 additions & 1 deletion
File tree
- packages/go_router
- lib/src
- pending_changelogs
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
508 | | - | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
509 | 511 | | |
510 | 512 | | |
511 | 513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
434 | 435 | | |
435 | 436 | | |
436 | 437 | | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
437 | 513 | | |
438 | 514 | | |
439 | 515 | | |
| |||
0 commit comments