Search overlay: Improve accessibility #9035
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.
Prerequisites
Description
I have been wanting to take a stab at this forever since reading this wonderful article https://nolanlawson.com/2019/11/05/what-ive-learned-about-accessibility-in-spas/ on my way home from #umbUkFest10 ❤️
It's the part under the headline "The final boss: accessible autocomplete", which inspired me to improve the search feature in the backoffice.
However due to how the search results are currently wrapped I'm not able to add the parts including the use of ´aria-activedescendant´ and the parts about
role="option"
so that's been omitted for now since I think it needs to be addressed in another PR - Unless @MMasey for or another brilliant person with BE skills is able to figure out if the data we get returned from the API call to /umbraco/backoffice/UmbracoApi/Entity/SearchAll could be changed around so we get all the results in one go but still with the ability to make a distinction between the categories etc. or maybe we can flatten the data we already receive in the FE somehow that I have not thought yet - It's something I would be happy to discuss at least :-)Ok, enough chatter - The following improvements have been made with this PR and they can stand alone as is
role="dialog"
,aria-describedby
andaria-labelledby
attributes along with asr-only
section containing the sreen reader friendly title and description, which are required for dialog's, which the search overlay is 😃<input>
and the<div>
containing the search results using ´aria-owns´, which is used when a normal parent/child markup relationship is not possible to achieve. This attribute connetcs the two by using the idsearch-results
tabindex="-1"
attribute on the clear button since we need to be able to tab to it in order for it to be accessible. It's an extra step before tabbing into the results but I think we will cope! Besides it's nice to tab to the clear button first incase you just want to cleae the search field 👼aria-hidden="true"
to the<div class="umb-search-group__title">
since anothersr-only
text have been added to announce where the item was found since theumb-search-group__title
makes sense in a visual context the screen reader is not picking up the name when tabbing / navigating back and forth using the up/down arrow keys. Hence this change<i>
to<umb-icon>
thoughout the viewOk, so a lot of stuff going on here - It's by purpose I have not added the
umb-focus.lock
directive since it does not handle adding focus on elements that are not there initially - This will be improved in the #8522 PR - Once it's done this view will need it too 😃