-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Selection Behavior 'replace' #2013
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
Conversation
add demo stories fix clicking without shift
|
Build successful! 🎉 |
|
Build successful! 🎉 |
|
Build successful! 🎉 |
LFDanLu
left a comment
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.
Mainly story things, but some odd cases noted as well
packages/@react-aria/selection/stories/useSelectableList.stories.tsx
Outdated
Show resolved
Hide resolved
packages/@react-aria/selection/stories/useSelectableList.stories.tsx
Outdated
Show resolved
Hide resolved
packages/@react-aria/selection/stories/useSelectableList.stories.tsx
Outdated
Show resolved
Hide resolved
packages/@react-aria/selection/stories/useSelectableList.stories.tsx
Outdated
Show resolved
Hide resolved
packages/@react-aria/selection/stories/useSelectableList.stories.tsx
Outdated
Show resolved
Hide resolved
packages/@react-aria/selection/stories/useSelectableList.stories.tsx
Outdated
Show resolved
Hide resolved
| <code>selectOnFocus</code> is true ❌ | ||
| </li> | ||
| </ol> | ||
| <List selectionMode="multiple" disallowEmptySelection> |
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.
Is this one is supposed to disallowEmptySelection? I can deselect all selection via clicking
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.
So I wasn't sure what to do with this one, the code in SelectionManager is VERY specific that disallowEmptySelection only applies to single selection
https://github.com/adobe/react-spectrum/blob/main/packages/@react-stately/selection/src/SelectionManager.ts#L369
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.
hmm, I guess it makes sense that disallowEmptySelection doesn't apply for multiselect, can't really think of a use case for that
| .add( | ||
| 'multiple selection selectionBehavior replace', | ||
| () => ( | ||
| <TableView aria-label="TableView with dynamic contents" selectionMode="multiple" selectionBehavior="replace" width={300} height={200} onSelectionChange={s => onSelectionChange([...s])}> |
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.
Feels odd to be unable to deselect a selected row by clicking its checkbox. Also noticed that shift + click doesn't quite work if you click on the row's checkbox cell
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.
Perhaps TableView should work a bit differently with replace?
EDIT: Ah I see, the CMD key modifier allows for this. Is there a spec somewhere that describes the expected behavior?
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.
So I was unable to figure out how to do this with Finder, however, you can select disparate files with the mouse by holding CMD, so I thought that might be a good way to approach this. Agreed, less than ideal that CMD + Space (which usually acts as a press) brings up the spotlight search, but I don't have a good alternative and I think it's a well known shortcut, so if someone hits that, they'd automatically try Enter anyways?
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.
I think that is reasonable, perhaps something to note in the docs
|
Build successful! 🎉 |
|
Build successful! 🎉 |
|
Build successful! 🎉 |
|
Build successful! 🎉 |
LFDanLu
left a comment
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.
Just one question but otherwise the behavior seems right to me
| // Keyboard events bubble through portals. Don't handle keyboard events | ||
| // for elements outside the collection (e.g. menus). | ||
| if (e.altKey || !ref.current.contains(e.target as HTMLElement)) { | ||
| if ((e.altKey && !e.ctrlKey) || !ref.current.contains(e.target as HTMLElement)) { |
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.
This addition is supposed to prevent ctrl + alt (aka control + option on Mac) from being handled by the child element right? Right now in https://reactspectrum.blob.core.windows.net/reactspectrum/83a514c745dcc6475b057e38ac23c3292b8c8770/storybook/index.html?path=/story/tableview--crud ctrl + alt + arrow down still opens the menu.
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.
that story isn't a replacement behavior, so it shouldn't need this anyways?
|
So I think there's a few things that need to happen here:
|
* Mobile updates for selection * Move mobile awareness to the component * fix lint * move to touch/vo detection
* Select on focus first time in collection * fix lint * Only start selecting on first focus if selectOnFocus is on * add a test * fix aria * fix lint * remove dead code * fix lint
|
Build successful! 🎉 |
|
Build successful! 🎉 |
|
Build successful! 🎉 |
Closes #2018
Adds selectionBehavior prop which can be
toggleorreplace. Previously, it was always toggle, this specifically adds replace.This is added for mouse/touch and keyboard is handled the way it is in Windows where alt + arrows will allow a user to navigate and select a non-contiguous set of items
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: