Fix: Enable typing in search field when semantics are enabled#37
Merged
cedvdb merged 4 commits intocedvdb:mainfrom Dec 24, 2025
Merged
Fix: Enable typing in search field when semantics are enabled#37cedvdb merged 4 commits intocedvdb:mainfrom
cedvdb merged 4 commits intocedvdb:mainfrom
Conversation
Removed conflicting Semantics and ExcludeSemantics widgets from the SearchBox to allow the TextField to correctly expose its own accessibility semantics. This resolves an issue where users could not type into the search field when screen readers or other accessibility tools were active.
5 tasks
Owner
|
thanks Regarding the test: Since we are not doing anything semantic related anymore, we let flutter handle it, the test file seems unnecessary, (if there is an issue, it is a flutter issue_. People are lazy, and this will quickly become ghost code because it's not automated, so I'm down to just remove that file. We could check include node etc, but again, that would be testing flutter, not anything we do here. |
Contributor
Author
|
Will do; I'll remove that |
Owner
|
release failed because there was no version update in the changelog. I'm going to revert, can you resubmit with an entry in the changelog for this version so that the deploy pipeline can do its job ? |
cedvdb
added a commit
that referenced
this pull request
Dec 24, 2025
cedvdb
added a commit
that referenced
this pull request
Dec 28, 2025
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.
This PR fixes a critical accessibility bug that made the search field in
CountrySelectorunusable when a screen reader (like VoiceOver or TalkBack) is active. TheTextFieldfor search was not focusable, preventing text input.How to Reproduce the Bug
To understand the bug with the previous code, you can run a widget test with semantics explicitly enabled. This mimics a user enabling a screen reader. The
TextFieldwould not be part of the semantics tree and thus would be completely inaccessible to a user relying on assistive technology.The following code demonstrates how to enable semantics for testing. On a device, this is equivalent to turning on VoiceOver or TalkBack.
The Problem
The root cause was the
TextFieldwithin the_SearchBoxwidget being wrapped by anExcludeSemanticswidget. This explicitly removed the search field and its children from the semantics tree, making it invisible and unusable to accessibility services.The Solution
The fix is to remove the
ExcludeSemanticsand its parentSemanticswidget that were wrapping theTextField. TheTextFieldwidget itself is already configured to handle its own semantics correctly, using the providedInputDecoration.hintTextas its accessibility label. This change allows screen readers to discover and interact with the search field as intended.Testing Strategy
Automated testing for this specific focus issue proved to be unreliable. The standard
tester.enterTextmethod does not use the semantics tree to find widgets, so it passed even when the bug was present. Attempts to programmatically check the focus status (viaSemanticsFlag.isFocused) were inconsistent across different test runs, especially when the selector was presented as a modal sheet.To provide a robust way to verify the fix, a new manual test case has been added in
test/manual_semantics_test.dart. This test launches the widget and pauses, allowing a developer to perform a real-world check.To run the manual test:
flutter test test/manual_semantics_test.dartin your terminal.Related Issues
Supporting Documentation
SemanticsWidget: The primary widget for providing accessibility information.ExcludeSemanticsWidget: The widget that was causing the issue by hiding theTextFieldfrom assistive technologies.