-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support onAction and isDisabled on item elements #5874
Conversation
Build successful! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move from state.disabledKeys to state.selectionManager is a bit unfortunate if anyone has written their own work on top of collections, but probably not very common and we can mention it in release notes
I forget, have we also discussed isSelected already as well?
yeah it shouldn't break because disabledKeys is still there, but just won't support the new feature until migrating. what about isSelected? |
did we want to support the same kind of thing? is that possible? I have a vague feeling it wasn't possible, but can't recall why |
you mean isSelected on individual items? I think that's not possible because multiple items can be selected at once, so onSelectionChange really needs to be on the root level. Makes sense to keep selectedKeys at the same level. |
Build successful! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I'll add a followup to add isDisabled to TreeItem as well
Build successful! 🎉 |
## API Changes
unknown top level export { type: 'any' } @react-aria/gridGridKeyboardDelegateOptions GridKeyboardDelegateOptions<C, T> {
collator?: Intl.Collator
collection: C
direction: Direction
+ disabledBehavior?: DisabledBehavior
disabledKeys: Set<Key>
focusMode?: 'row' | 'cell'
layout?: Layout<Node<T>>
ref?: RefObject<HTMLElement>
it changed:
|
Relates to #5058 #5459
This adds support for the
onAction
andisDisabled
props directly on collection items in addition to the existing collection-levelonAction
anddisabledKeys
. In some cases it can be easier to set these props at an item level, for example with static collections (e.g. common in menus). If both are provided, an item is disabled if either theisDisabled
prop is set or its key is indisabledKeys
, and bothonAction
handlers are called.Note that while this is implemented in the hooks, these props are only in the TS definitions for RAC and not RSP (or the older stately collections). Since RSP uses a single
<Item>
component across all components, we can't easily add props to some components but not others. In RAC we separated these out into separate components so this is possible.