Skip to content

fix: add keyboard accessibility and ARIA roles to cog menu#2727

Open
pintaste wants to merge 1 commit into
simonw:mainfrom
pintaste:fix/cog-menu-keyboard-accessibility
Open

fix: add keyboard accessibility and ARIA roles to cog menu#2727
pintaste wants to merge 1 commit into
simonw:mainfrom
pintaste:fix/cog-menu-keyboard-accessibility

Conversation

@pintaste
Copy link
Copy Markdown

The cog menu dropdown currently cannot be navigated by keyboard after opening — arrow keys don't move focus between items, and there are no ARIA attributes for screen readers.

This PR adds:

  • aria-haspopup="menu" and aria-expanded on the <summary> toggle button, kept in sync via a toggle event listener
  • role="menu" on the dropdown <ul> container
  • role="menuitem" and tabindex="-1" on each menu item <a>
  • Focus moves to the first menu item when the menu opens
  • Arrow key navigation (Up/Down) between menu items
  • Escape key closes the menu and returns focus to the toggle button

Fixes #2724

- Add aria-haspopup="menu" and aria-expanded to summary element
- Add role="menu" to dropdown ul, role="menuitem" and tabindex="-1" to links
- Sync aria-expanded via toggle event listener
- Focus first menu item when menu opens
- Add ArrowDown/ArrowUp navigation between menu items
- Add Escape key to close menu and return focus to summary

Fixes simonw#1964
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.

/ table search menu is broken in Safari

1 participant