Improve accessibility of Orders Autosuggest #3321
Merged
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.
Description of the Change
Improves the accessibility of Orders Autosuggest by:
aria-activedescendant
on the input element, so that selected options are properly read out by screen readers.aria-haspopup
, which has a redundant announcement and is no longer recommended.aria-describedby
to the input which points to a hidden element that communicates how to navigate suggestions, as well as the current number of suggestions.The results are not perfect. VoiceOver on macOS has a tendency to interrupt itself and the tools to deal with this are limited. Fundamentally I'm not convinced that a
combobox
is the correct approach to these kind of suggestions, but this is at least consistent with what's being done everywhere else, such as GitHub, and the user experience is great for sighted keyboard and mouse users. More research is needed here.This PR also changes how the input field is managed by the React app. Previously it was left as-is, and attributes where managed on the input by interacting with the element in
useEffect()
hooks. Now the input is part of the combobox component and the original input is entirely replaced by the combobox rendered by the React app. This makes development of the component far easier, and will simplify iteration.Closes #3314
How to test the Change
Down
should navigate to the first suggestion. PressingUp
should navigate to the last suggestion.Command
(orControl
on Windows) while doing so should open it in a new tab.Command
(orControl
on Windows) while doing so should open it in a new tab.Escape
key should close the list. PressingEscape
a second time should empty the search field.Up
orDown
should open the list again.$post-search-input-description
element should provide instructions that include the number of elements, eg. 3 suggestions available, use the up and down keys to browse and the enter key to open. The word "suggestions" should be properly pluralised based on the number of results.Changelog Entry
Credits
Props @JakePT
Checklist: