Skip to content

fix(site/src): add visible keyboard focus indicator to menu items - #30355

Closed
chrifro wants to merge 1 commit into
mainfrom
fix-menu-item-focus-ring
Closed

chrifro wants to merge 1 commit into
mainfrom
fix-menu-item-focus-ring

Conversation

@chrifro

@chrifro chrifro commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Keyboard focus on dropdown menu items was not visible in some cases. Checked radio items use the same bg-surface-secondary background as the focus state, so focusing the selected proxy in the latency menu changed nothing on screen (axe Auditor issue 2864584, WCAG 2.4.7 Focus Visible). Other items such as "Proxy settings" and "Refresh latencies" only had a subtle background change.

This adds a shared menuItemFocusClass (focus-visible:ring-2 ring-inset ring-content-link, the same focus color used by Button, Link, and Tabs) to menuItemClass and DropdownMenuRadioItem. Every DropdownMenu and ContextMenu item type (item, checkbox, radio, sub-trigger) picks it up. The ring is inset so scrollable menu containers cannot clip it, and :focus-visible keeps it off pointer hover. A new OpenedWithKeyboard story covers the state in Pixel.

Before After
Focused checked radio item ("Default") before: checked item focused, no indicator after: checked item focused with blue ring
Focused regular item ("Refresh latencies") before: refresh latencies focused, background only after: refresh latencies focused with blue ring
Decision log
  • Root cause: DropdownMenuRadioItem applies bg-surface-secondary for both focus and data-[state=checked], so the checked item has no focus delta.
  • Fixed in the shared menu classes rather than in ProxyMenu, so every current and future menu item gets the indicator.
  • Inset ring instead of an outer ring: DropdownMenuContent uses overflow-hidden and ProxyMenu wraps items in an overflow-y-auto container, both of which clip an outer ring.
  • :focus-visible instead of :focus/data-highlighted: Radix focuses items on pointer move, so a :focus ring would also show on mouse hover. Verified in the dev server that after a mouse click, hovering an item does not show the ring, while arrow-key navigation does.
  • Out of scope: Select, Autocomplete, and MultiSelectCombobox options, which do not use menuClasses.

Note

Generated by Coder Agents on behalf of @chrifro.

Checked dropdown radio items share the focus background, so keyboard
focus on the selected item was invisible. Add a shared inset focus ring
to all dropdown and context menu items.
@chrifro

chrifro commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Closing as a duplicate of #30354, which fixes the same menu item focus ring in the shared menuClasses/DropdownMenuRadioItem and also hides it on hover. The OpenedWithKeyboard ProxyMenu story from this PR moved to #30354.

Generated by Coder Agents on behalf of @chrifro.

@chrifro chrifro closed this Oct 5, 2026
@chrifro
chrifro deleted the fix-menu-item-focus-ring branch October 5, 2026 12:55
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant