Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix navigation links in the header not being announced by screen readers #1967

Merged
merged 2 commits into from
Sep 22, 2020

Conversation

36degrees
Copy link
Member

In 18771ce (released as part of v3.9.0) we changed the logic of the header javascript to set the aria-expanded and aria-hidden attributes on the menu button and navigation respectively.

However, the logic is applied at all breakpoints, not just the mobile breakpoint where the navigation is hidden, and so the navigation is currently not visible to screen reader users.

As noted by @adamsilver, in this instance when the navigation is hidden it is already removed from the accessibility tree through the use of display: none;. As such, the aria-hidden attribute is redundant and can be removed:

If an interactive element is hidden using display:none or visibility:hidden (either on the element itself, or any of the element's ancestors), it won't be focusable, and it will also be removed from the accessibility tree. This makes the addition of aria-hidden="true" or explicitly setting tabindex="-1" unnecessary.

https://www.w3.org/TR/using-aria/#4thrule

This means that the only aria attribute we need to keep in sync is the aria-expanded attribute – which is applied to the menu control which is hidden when the menu is not collapsible, so it being ‘out of sync’ on the desktop breakpoint is not an issue.

Fixes #1966.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1967 September 22, 2020 12:48 Inactive
In 18771ce (released as part of v3.9.0) we changed the logic of the header javascript to set the aria-expanded and aria-hidden attributes on the menu button and navigation respectively.

However, the logic is applied at all breakpoints, not just the mobile breakpoint where the navigation is hidden, and so the navigation is currently not visible to screen reader users.

As noted by @adamsilver, in this instance when the navigation is hidden it is already removed from the accessibility tree through the use of `display: none;`. As such, the `aria-hidden` attribute is redundant and can be removed:

> If an interactive element is hidden using display:none or visibility:hidden (either on the element itself, or any of the element's ancestors), it won't be focusable, and it will also be removed from the accessibility tree. This makes the addition of aria-hidden="true" or explicitly setting tabindex="-1" unnecessary.
>
> https://www.w3.org/TR/using-aria/#4thrule

This means that the only aria attribute we need to keep in sync is the `aria-expanded` attribute – which is applied to the menu control which is hidden when the menu is not collapsible, so it being ‘out of sync’ on the desktop breakpoint is not an issue.

Fixes #1966.
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1967 September 22, 2020 12:53 Inactive
@36degrees 36degrees changed the title Do not set aria-hidden on header navigation Fix navigation links in the header not being announced by screen readers Sep 22, 2020
Copy link
Contributor

@vanitabarrett vanitabarrett left a comment

Choose a reason for hiding this comment

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

Tested on desktop and mobile and seems to work as intended now... 👍

@36degrees 36degrees merged commit 8d7eeb8 into master Sep 22, 2020
@36degrees 36degrees deleted the header-aria-hidden branch September 22, 2020 13:28
@36degrees 36degrees mentioned this pull request Sep 22, 2020
@paulrobertlloyd
Copy link
Contributor

The turnaround time on this issue is really impressive! Thanks for fixing @36degrees!

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.

Header navigation is hidden from assistive technologies on tablet/desktop view
5 participants