Skip to content

feat(core): keyboard navigation for List menus and submenus - #600

Merged
ggdaltoso merged 1 commit into
React95:masterfrom
Saisinare:feat/list-keyboard-navigation
Nov 10, 2026
Merged

ggdaltoso merged 1 commit into
React95:masterfrom
Saisinare:feat/list-keyboard-navigation

Conversation

@Saisinare

Copy link
Copy Markdown
Contributor

List's submenus only opened on CSS :hover, so they could not be reached with the keyboard. List now follows the WAI-ARIA menu pattern:

  • role="menu" on lists, role="menuitem" on items, role="separator" on dividers; items with a submenu get aria-haspopup and aria-expanded
  • a single tab stop for the menu (roving tabindex), with Up/Down to move between items, wrapping around, and Home/End to jump to the ends
  • Right (or Enter/Space) opens a submenu and moves into it; Left or Esc closes it and returns to its item
  • Enter/Space on an item without a submenu clicks it, so onClick runs as it does for the mouse

Hover keeps working as before, and the TaskBar start menu is unchanged. List > With Icons tests the keyboard steps in its play function, and List > Simple tests that Enter and Space click the focused item.

Closes #566

Copilot AI balanced review requested due to automatic review settings October 20, 2026 13:20
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ggdaltoso

ggdaltoso commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Thanks, @Saisinare!

This follows the menu pattern closely, and the play covers every keyboard step. Leaving Esc on the top menu to whatever opened it is a nice touch.

One thing: clicking an item focuses it, and &:focus keeps it highlighted, so hovering another item leaves two items highlighted at once. Using :focus-visible instead fixes it, since a mouse click doesn't trigger it but the keyboard does:

'&:hover, &:focus-visible, &[aria-expanded="true"]': {

and the same for &:has(ul):focus-visible:after.

Also, could you drop the Co-Authored-By: Claude trailer from the commit message? git commit --amend opens the message so you can delete that line, then git push --force-with-lease.

@Saisinare
Saisinare force-pushed the feat/list-keyboard-navigation branch from 15e6707 to 0287094 Compare November 9, 2026 15:10
@Saisinare

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Switched both to :focus-visible and dropped the trailer.

List's submenus only opened on CSS :hover, so they could not be reached
with the keyboard. List now follows the WAI-ARIA menu pattern:

- role="menu" on lists, role="menuitem" on items, role="separator" on
  dividers; items with a submenu get aria-haspopup and aria-expanded
- a single tab stop for the menu (roving tabindex), with Up/Down to move
  between items, wrapping around, and Home/End to jump to the ends
- Right (or Enter/Space) opens a submenu and moves into it; Left or Esc
  closes it and returns to its item
- Enter/Space on an item without a submenu clicks it, so onClick runs as
  it does for the mouse

Hover keeps working as before, and the TaskBar start menu is unchanged.
List > With Icons tests the keyboard steps in its play function, and
List > Simple tests that Enter and Space click the focused item.

Closes React95#566
@ggdaltoso
ggdaltoso force-pushed the feat/list-keyboard-navigation branch from 0287094 to 8ebb658 Compare November 9, 2026 15:32
@nx-cloud

nx-cloud Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 8ebb658

Command Status Duration Result
nx affected -t lint,test,build,test-storybook,b... ✅ Succeeded 2m 18s View ↗
nx-cloud record -- yarn nx format:check ✅ Succeeded 1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-11-10 13:22:12 UTC

@ggdaltoso

Copy link
Copy Markdown
Member

Thanks, @Saisinare! The List menus can now be used with the keyboard, submenus included. 🎉

@all-contributors please add @Saisinare for code and a11y

@allcontributors

Copy link
Copy Markdown
Contributor

@ggdaltoso

I've put up a pull request to add @Saisinare! 🎉

@ggdaltoso
ggdaltoso merged commit a05cc59 into React95:master Nov 10, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

List: keyboard navigation for menus and submenus

3 participants