Skip to content

fix(a11y): improve YaruAutocomplete accessibility and focus traversal - #1077

Open
paul-geoghegan wants to merge 1 commit into
ubuntu:mainfrom
paul-geoghegan:1076-A11Y-improving-autocomplete
Open

fix(a11y): improve YaruAutocomplete accessibility and focus traversal#1077
paul-geoghegan wants to merge 1 commit into
ubuntu:mainfrom
paul-geoghegan:1076-A11Y-improving-autocomplete

Conversation

@paul-geoghegan

@paul-geoghegan paul-geoghegan commented Apr 23, 2026

Copy link
Copy Markdown

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.

Resolves focus traps, adds screen reader announcements via SemanticsService, and safely handles async search race conditions without breaking parent widget focus nodes.

@ashuntu ashuntu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +123 to +125
SemanticsService.announce('Input cleared', TextDirection.ltr);
} else if (count == 0) {
SemanticsService.announce('No options found', TextDirection.ltr);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These strings should be able to be passed in to the YaruAutocomplete as optional fields. Perhaps also the announce text direction.

Comment on lines +132 to +134
final message = count == 1
? '1 option available'
: '$count options available';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use a YaruAutocomplete field for these TextDirections so they can be overridden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A11Y: improving autocomplete

3 participants