Repository navigation
[Menu] Option to keep disabled items keyboard-navigable (WAI-ARIA APG) #3664
MichalBaran94
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
💡 Your idea
🚀 Feature request
Add an opt-in option to the menu machine that keeps disabled items in keyboard navigation (arrow keys, Home/End, typeahead), while they stay non-activatable.
🧱 Problem Statement / Justification
Disabled items are removed from keyboard navigation, because the item query excludes
[data-disabled]:zag/packages/machines/menu/src/menu.dom.ts
Lines 58 to 61 in f6f33ea
As a result, a keyboard or screen reader user can't reach a disabled item at all:
aria-describedby) is unreachable. A common case is a disabled item with a tooltip that says why it is disabled. Mouse users can hover it, keyboard users can't get to it.The WAI-ARIA Authoring Practices recommend the opposite for menus:
(Menu and Menubar pattern)
(Focusability of disabled controls)
✅ Proposed solution or API
An opt-in prop on the menu, for example
focusDisabledItems(the name is up to you), with defaultfalseso nothing changes for existing users.When enabled:
data-highlightedand are referenced byaria-activedescendantaria-disabled="true"The activation guards already exist (
getItemPropsreturns early when the item is disabled), so the change looks limited to the query ingetElements.↩️ Alternatives
aria-disabledto the item instead ofdisabled. This is fragile, because the item is then not disabled for the machine:onSelectand close-on-select still fire unless the click is intercepted by hand.getElementslocally, which has to be carried over on every upgrade.📝 Additional Information
Checked on
@zag-js/menu1.41.2 and onmain(1.48.0). Used through Ark UI / Chakra UI v3.Title field, after their prefix:
All reactions