-
Notifications
You must be signed in to change notification settings - Fork 1.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
🐛 Selection change when selectable list focuses #7512
Comments
alirezamirian
added a commit
to alirezamirian/react-spectrum
that referenced
this issue
Dec 12, 2024
5 tasks
alirezamirian
changed the title
Selection change when selectable list focuses
🐛 Selection change when selectable list focuses
Dec 12, 2024
alirezamirian
added a commit
to alirezamirian/jui
that referenced
this issue
Dec 12, 2024
alirezamirian
added a commit
to alirezamirian/react-spectrum
that referenced
this issue
Dec 13, 2024
Seems reasonable. I see Outlook's selection works like this, as does Mac Finder if I change windows and come back. |
alirezamirian
added a commit
to alirezamirian/react-spectrum
that referenced
this issue
Dec 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Provide a general summary of the issue here
When using
useSelectableCollection
withselectOnFocus
set totrue
and with some selected keys, focusing the list for the first time changes the selection. It's easier to see it in action in the codesandbox linked below.🤔 Expected Behavior?
When focusedKey is initialized upon first focus, the focused item should also be selected if
selectOnFocus
is true, but only if the focus is going to a key not already selected. i.e focusing a collection with initially selected items should not have the side effect of selection being changed.😯 Current Behavior
Initial non-empty selection can change upon focus.
💁 Possible Solution
The bug is in the code that tries to initialize
focusedKey
upon the first focus:react-spectrum/packages/@react-aria/selection/src/useSelectableCollection.ts
Lines 346 to 364 in 326f481
If the
key
passed tonavigateToFirstKey
is eithermanager.lastSelectedKey
ormanager.firstSelectedKey
selection should not be toggled, as the item that's about to get focused is already selected.See #7513
🔦 Context
No response
🖥️ Steps to Reproduce
Self explanatory sandbox: https://codesandbox.io/p/sandbox/blissful-joliot-gysfg2
Version
@react-aria/[email protected]
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
macOS
🧢 Your Company/Team
https://github.com/alirezamirian/jui
🕷 Tracking Issue
No response
The text was updated successfully, but these errors were encountered: