chore: document useKeyboard shortcuts#10192
Conversation
|
Build successful! 🎉 |
## API Changes
@react-aria/menu/@react-aria/menu:AriaMenuItemProps AriaMenuItemProps {
aria-controls?: string
aria-describedby?: string
aria-expanded?: boolean | 'true' | 'false'
aria-haspopup?: 'menu' | 'dialog'
aria-label?: string
id?: string
isVirtualized?: boolean
key: Key
onBlur?: (FocusEvent<Target>) => void
onClick?: (MouseEvent<FocusableElement>) => void
onFocus?: (FocusEvent<Target>) => void
onFocusChange?: (boolean) => void
onHoverChange?: (boolean) => void
onHoverEnd?: (HoverEvent) => void
onHoverStart?: (HoverEvent) => void
onKeyDown?: (KeyboardEvent) => void
onKeyUp?: (KeyboardEvent) => void
onPress?: (PressEvent) => void
onPressChange?: (boolean) => void
onPressEnd?: (PressEvent) => void
onPressStart?: (PressEvent) => void
onPressUp?: (PressEvent) => void
selectionManager?: SelectionManager
+ shortcuts?: KeyboardShortcutBindings
shouldCloseOnSelect?: boolean
} |
Agent Skills ChangesModified (2)
InstallReact Spectrum S2: React Aria: |
| selectionManager?: SelectionManager; | ||
|
|
||
| /** Keyboard shortcuts to handle. */ | ||
| shortcuts?: KeyboardShortcutBindings; |
There was a problem hiding this comment.
probably shouldn't add this as a prop
There was a problem hiding this comment.
Yeah, i was unsure the best way to handle this. The issue is that if shortcuts doesn't handle it, we automatically call continuePropagation on it. The issue though is that useMenuItem and useSubmenuTrigger are attaching keyboard handlers to the same element, through the same useKeyboard because we pass onKeyDown/onKeyUp straight through on the props.
I'll try something new on monday to see if i can undo this.
There was a problem hiding this comment.
yeah fwiw daniel ran into the same thing in combobox I think, one of the reasons we reverted for this release. he had some ideas but ultimately it seemed too risky for now
There was a problem hiding this comment.
yeah, i chatted with him about it, makes sense
Closes
Also swaps the order of props.onKeyDown and our shortcut handler so that in the future it'll be possible to prevent the aria defaults.
Note this came with a change that I needed to pass the shortcuts object to a menu item, not just the handlers, otherwise continuePropagation was being called when it shouldn't be.
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: