fix(a11y): improve YaruAutocomplete accessibility and focus traversal - #1077
fix(a11y): improve YaruAutocomplete accessibility and focus traversal#1077paul-geoghegan wants to merge 1 commit into
Conversation
Resolves focus traps, adds screen reader announcements via SemanticsService, and safely handles async search race conditions without breaking parent widget focus nodes.
There was a problem hiding this comment.
Tested locally and it does seem to resolve a lot of the issues with the screen reader.
I know there's some ongoing discussions about translations. At a minimum I think the strings added should be overridable by the caller.
Also, make sure to bump .fvmrc and pubspec.yaml Flutter versions to at least 3.41.x, since announcements don't work on Linux before then.
There's also some analyzer errors to resolve https://github.com/ubuntu/yaru.dart/actions/runs/24838240076/job/72717452809?pr=1077
| SemanticsService.announce('Input cleared', TextDirection.ltr); | ||
| } else if (count == 0) { | ||
| SemanticsService.announce('No options found', TextDirection.ltr); |
There was a problem hiding this comment.
These strings should be able to be passed in to the YaruAutocomplete as optional fields. Perhaps also the announce text direction.
| final message = count == 1 | ||
| ? '1 option available' | ||
| : '$count options available'; |
There was a problem hiding this comment.
This text should also be able to be passed in as an optional field for YaruAutocomplete, maybe as a callback since the string needs to know about the result count. The translations we use in our apps have support for plurals, so in the ideal case we wouldn't need to do this special handling when using translated strings. Example: https://github.com/canonical/desktop-security-center/blob/main/packages/security_center/lib/l10n/app_en.arb#L35
| final option = _latestOptions.first; | ||
| SemanticsService.announce( | ||
| widget.displayStringForOption(option), | ||
| TextDirection.ltr, |
There was a problem hiding this comment.
We should use a YaruAutocomplete field for these TextDirections so they can be overridden.
fixes #1076
Resolves focus traps, adds screen reader announcements via SemanticsService, and safely handles async search race conditions without breaking parent widget focus nodes.
There is still the outstanding issue of i18n as this pr only uses English strings currently so we would need to figure out how best to move forward before this fix can be fully implemented.