Skip to content

Bugfix - Fix Dropdown keyboard focus and hover/tabindex coupling#53

Closed
markmead wants to merge 1 commit into
mainfrom
bugfix/dropdown-keyboard-focus-tabindex
Closed

Bugfix - Fix Dropdown keyboard focus and hover/tabindex coupling#53
markmead wants to merge 1 commit into
mainfrom
bugfix/dropdown-keyboard-focus-tabindex

Conversation

@markmead

@markmead markmead commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • toggleMenu() now focuses the first menu item when it opens the menu, fixing a bug where menus opened via mouse click or Enter/Space on the trigger left every item at tabindex="-1" (Tab would skip past the open menu entirely — only ArrowDown/ArrowUp previously set focus correctly).
  • Removed the x-on:mouseenter handlers driving the roving tabindex/highlight in the Dropdown demo, so hovering with a mouse no longer relocates the keyboard tab stop. Visual hover highlighting is unaffected (already handled by the existing hover:bg-gray-100 classes).
  • Documented the new toggleMenu() focus behavior in the Behavior Contract and Accessibility Notes sections of dropdown.mdx, plus a note on role="menu" semantics for nav-heavy menus.

Test plan

  • pnpm lint
  • pnpm check
  • Manual: open menu via mouse click, confirm Tab reaches a menu item
  • Manual: open menu via Enter/Space on trigger, confirm focus lands on first item
  • Manual: open menu via ArrowDown/ArrowUp, confirm existing behavior unchanged
  • Manual: hover over items with mouse, confirm highlight still shows without moving keyboard focus

🤖 Generated with Claude Code

Menus opened via mouse click or Enter/Space left every item at
tabindex="-1", so keyboard users could open the menu but Tab would skip
past it entirely. toggleMenu() now focuses the first item on open,
matching the existing ArrowDown/ArrowUp behavior. Also stopped mouse
hover from moving the roving tabindex target, since hover highlighting
was already covered by the existing hover: classes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
hyperux 00e5751 Commit Preview URL

Branch Preview URL
Jul 03 2026, 10:12 PM

@markmead markmead closed this Jul 11, 2026
@markmead
markmead deleted the bugfix/dropdown-keyboard-focus-tabindex branch July 15, 2026 07:22
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