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

Improve nav semantics and functionality #73

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

marcysutton
Copy link

@marcysutton marcysutton commented Aug 29, 2024

The nav block included in the AEM block collection has some accessibility issues that need to be fixed:

  1. The nav has aria-expanded on it in desktop mode even though it's always expanded. This attribute isn't really helpful for screen readers in this context.
  2. The nav dropdowns use the tabindex attribute and keyboard events on listitem elements that are inaccessible to screen reader users. When navigating with VoiceOver and other screen readers, the text and number of list items are announced but there is no indication these items are interactive.

In this PR, I made the following changes:

  1. Only apply aria-expanded to the nav when isDesktop.matches evaluates to false. The mobile view is still styled off of aria-expanded and marked with the current ARIA state like it was before.
  2. The nav-drop components have button elements that are keyboard and screen reader interactive. This preserves the list role and semantics for the containing element, while creating an accessible affordance that indicates the correct role, state, and property for an interactive dropdown toggle. The top-level nav items are still interactive with the mouse.

By merging these changes into the base repository, every consumer of the code will benefit from a more accessible starting point.

Note: One thing I considered was wrapping the top-level nav item text in a button since the whole thing is clickable (e.g. "Default Content"). But in my own AEM project implementation, I found that wrapping the item text from a nav-drop while excluding the UL child is pretty complicated. I chose to keep this version simple intentionally for that reason.

Test URLs:

Copy link

aem-code-sync bot commented Aug 29, 2024

Page Scores Audits Google
M / PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
D / PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@trieloff trieloff requested a review from fkakatie September 2, 2024 12:42
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.

1 participant