ARIA/accessibility fixes for mobile menu and search/typeahead #4456
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.
Summary (required)
The work for this PR was originally to address issue 4183
aria-hidden="true"] elements contain focusable descendants
on the homepage.Since the mobile menu and its child global search filed appear on every page of the site, I decided to combine the fixes for these into one PR. This also extended to datable search fields that use typeahead.
Also partially addressed:
#4185 [aria-*] attributes do not have valid values
[aria-*] attributes do not match their roles
[role]s do not have all required [aria-*] attributes
Failing elements and their fixes:
The mobile menu failed
aria-hidden="true"] elements contain focusable descendants
(4183) because it maintains focusability on child elements when closed(aria-hidden='true')-1
on mobile menu links while ,menu is closed and add tab index to0
when menu is expanded. (site-nav.js
)The global site search failed for
ARIA IDs are not unique
(4186) because there are two search boxes on the page, one being hidden/shown based on screen size. Followup issue to come.site-nav.js
)MediaQueryList
matchMedia
Testing media queries programmatically
This allows us to handle the two locations of the global searchbox until we can redesign the header to persist one searchbox regardless of screen/device size. not supported inn IE, just giving the user a searchbox in different, but not ugly location the rare scenario that a user resizes with mobile menu open.
The global site search field typeahead dropdown and datable search fields that use the typeahead failed for
[aria-*] attributes do not have valid values
(4185,) and two that did not have corresponding tickets[aria-*] attributes do not match their roles
AND[role]s do not have all required [aria-*] attributes
typeahead.js
,filter-typeahead.js
)Additional fix was also made based on documented ARIA requirements although they may not have triggered a Lighthouse failing flag. The typeahead fields have a role of combobox and require
aria-expanded
roles to be set based on the state of the typeahead suggestion popup.aria-expanded
tags based on the state of the search field and associated typeahead popup. (typeahead.js
,filter-typeahead.js
)Another accessibility issue that was brought to light by this work was the inconsistent tab navigation for the mobile menu which could translate to lack of navigability for screen readers.
navigation.html
)The "More" dropdown checkbox list for Report Time Period on datatables
.dropdown__panel
starts witharia-hidden=false
, but has focusable elements with tabindex=0. This did not get flagged by Lighthouse but seems to violatearia-hidden="true"] elements contain focusable descendants
.dropdown.js
)Remove tabindex on Mega Menu links to avoid
[aria-hidden="true"]
elements contain focusable descendants ondiv#site-menu.site-nav__container
.Note: This worked in most browsers but made the dropdowns inoperable in Safari so this change was reverted in hotfix:
[MERGE WITH GITFLOW] Fix Safari bug with desktop-size menu #4495
Impacted areas of the application
Screenshots
BEFORE:
AFTER:
How to test
aria-expanded=true
when the typeahead suggestion box is visible andaria-expanded=false
when it is collapsedNote: The mobile toggle button may be missing at certain screen widths on your local because if the env specific banner -- you could resize until you see the button or remove the banner in the inspector