brand
brand copied to clipboard
[a11y] `SubNav` accessibility issues
- Focus trap activates even when there is no submenu or popup https://github.com/primer/brand/issues/761
- On mobile, once you enter into a focus trap in a submenu, there is no way to reach the close button if you are using your keyboard. The only way to exit the focus trap is by pressing Esc. Fixing the focus trap issue and rethinking the layout will provide a solution for this. I think focus trap needs to include the item to close the menu.
-
aria-current="page"
should not be a link if it has a submenu it should be abutton
, if it doesn't have a submenu, if it doesn't have a submenu it can remain a link since it has thearia-current="page"
. Submenu toggles have a button that activates them which is separate from the link. I think it should all be one button. We should basically discourage the usage of#
value for thehref
. - Submenus don't have their own focus trap and you cannot exit them by pressing Esc.
- Mobile dropdown menu toggle button maybe needs an
aria-haspopup="menu"
? Maybe alsoaria-controls="ID"
if we perform the restructure. - Mobile menu pushes the content down on tablet sizes when toggled on, but then on mobile the whole SubNav becomes absolutely positioned - which is an inconsistent behavior. I suggest that the nav items only are always absolutely positioned on tablet/mobile sizes and the SubNav containing element is positioned relatively. We can always change it's positioning in custom scenarios.
- We can maybe have the
ul
element ornav
labeled by the nav heading witharia-labeledby="ID"
? Or maybe this is automatically understood since the heading is inside thenav
element? We should check how the screen reader reads this. This might be useful if we restructure the SubNav a bit to accommodate for other issues. - Not entirely an a11y issue, but can we have an option for the heading to choose the element type like with an optional attribute
as
like we have on some other components. Could be useful! ✨