-
Notifications
You must be signed in to change notification settings - Fork 29.8k
a11y improvements for textfield #40390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| } else if (!isFocused && label != null) { | ||
| visitor(label); | ||
|
|
||
| if (isFocused) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure if it is any better, but it feels like these if statements could be re-arranged.
"Always add the label. Add the hint if it is focused, otherwise add the hint if there is no label."
if (label != null) {
visitor(label);
}
if (hint != null) {
if (isFocused) {
visitor(hint);
} else if (label == null) {
visitor(hint)
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks cleaner. Changed.
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
with nit on ifs
Description
An unfocused text field should add the label to the semantics tree. If no label is given, use the hint. A focused text field should include the label followed by the hint.
Related Issues
#38940
#39918
Tests
I added the following tests:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?