WIP - Improve Scaffold accessibility by defining a logical traversal order for its slots#184730
Draft
Piinks wants to merge 2 commits intoflutter:masterfrom
Draft
WIP - Improve Scaffold accessibility by defining a logical traversal order for its slots#184730Piinks wants to merge 2 commits intoflutter:masterfrom
Piinks wants to merge 2 commits intoflutter:masterfrom
Conversation
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Towards #184077
I need to try another solution first though.
Summary
This PR improves the accessibility of the Scaffold widget by explicitly defining the focus and
semantics traversal order for its various slots. This ensures that users of assistive technologies
(keyboard navigation and screen readers) encounter elements in a logical, top-down order,
prioritizing navigation and primary actions before main content.
Related Issue
Fixes #184077
The Problem
Previously, the traversal order in a Scaffold was determined by the build/layout order within its
internal CustomMultiChildLayout. This often resulted in the body being traversed before the
FloatingActionButton (FAB) or BottomNavigationBar. If the body contained a long scrollable list,
users were effectively "trapped" in the content and forced to navigate through every list item
before they could reach global navigation or the primary page action (FAB).
The Solution: "Chrome-before-Content"
This change implements a "Chrome-before-Content" traversal pattern. By prioritizing the AppBar,
BottomNavigationBar, and FloatingActionButton before the body, users can quickly switch context or
perform primary actions without traversing the entire main content area.
The final defined order is:
Key Navigation Benefits:
the AppBar, before entering the body.
back to the primary action or navigation.
Technical Implementation
Semantics container to enable sorting.
(NumericFocusOrder) and Semantics.sortKey (OrdinalSortKey) to each slot.
cleaner and more robust semantics tests for widgets like IconButton.
Tests
New Tests
full forward/backward Tab sequence and the correct assignment of semantics sort keys.
Updated Tests
Several existing regression tests were updated to accommodate the new semantics tree structure
(which now includes sorting nodes):
original intent of testing unmerged semantics nodes without interference from Scaffold's
internal containers.
more robust and focused on behavior rather than exact tree depth.
flexible_space_bar_test.dart, dropdown_menu_test.dart, and navigation_rail_test.dart: Updated
to match the new semantics nesting while preserving their original verification logic.
Verified that all updated tests and related suites (app_bar_test.dart, banner_test.dart,
snack_bar_test.dart, scaffold_test.dart) pass.
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.