fix: onSelectionChange should not be called for tabs that are links#9967
fix: onSelectionChange should not be called for tabs that are links#9967snowystinger wants to merge 2 commits into
Conversation
| * Whether to skip resetting the selection when a link is selected. | ||
| * @default false | ||
| */ | ||
| shouldSkipResetSelection?: boolean |
There was a problem hiding this comment.
not thrilled with this prop, but I haven't figured out a better one that matches behaviour
|
Build successful! 🎉 |
|
Why should onSelectionChange not be called? If the selectedKey is controlled it shouldn't affect anything anyway. Several other components also have |
|
The issue is that links actually behave differently anyways and reset the selected key. That's what this is skipping. https://github.com/adobe/react-spectrum/pull/9967/changes#diff-daad97dc33ab4579bed0b1334d9e2acc3f563b18a8de0cbf20a65220f13ac3acR151 I can see an argument that skipping isn't quite right, but it also already doesn't cause selection due to |
# Conflicts: # packages/react-aria/src/selection/useSelectableItem.ts
|
Build successful! 🎉 |
## API Changes
@react-aria/selection/@react-aria/selection:SelectableItemOptions SelectableItemOptions {
allowsDifferentPressOrigin?: boolean
focus?: () => void
id?: string
isDisabled?: boolean
isVirtualized?: boolean
key: Key
linkBehavior?: 'action' | 'selection' | 'override' | 'none' = 'action'
onAction?: () => void
ref: RefObject<FocusableElement | null>
selectionManager: MultipleSelectionManager
shouldSelectOnPressUp?: boolean
+ shouldSkipResetSelection?: boolean = false
shouldUseVirtualFocus?: boolean
} |
Agent Skills ChangesModified (2)
InstallReact Spectrum S2: React Aria: |
Closes #5252
Currently, not only is onSelectionChange called, but it's called with the previous value. This is due to a line in useSelectableItem which forces the selected key to be reset to the previous value.
When a tab is a link, it's not responsible for determing what the link does, any synchronization should be done by the user.
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: