Repository navigation
Fix select all in multi-select Select - #10977
Bhavani2016 wants to merge 2 commits into
Conversation
|
You're failing lint |
Thanks for catching this. I fixed the formatting and React Compiler lint errors. yarn lint now passes locally with zero warnings or errors, and all 40 Select tests pass. |
| .filter(item => item != null); | ||
| }, [listState.selectionManager.selectedKeys, listState.collection]); | ||
|
|
||
| let validationState = useFormValidationState({ |
| export function useListState<T>(props: ListProps<T>): ListState<T> { | ||
| export function useListState<T>( | ||
| props: ListProps<T>, | ||
| onSelectionChange?: ( |
There was a problem hiding this comment.
what? what's even using this?
we aren't adding other args to this hook at this time
| // impossible, but TS doesn't know that | ||
| if (keys === 'all') { | ||
| return; | ||
| keys = new Set( |
There was a problem hiding this comment.
the comment just above contradicts the use of this branch
| await selectTester.open(); | ||
| expect(selectTester.getListbox()).toContainElement(document.activeElement); | ||
|
|
||
| let modifier = /Mac/.test(navigator.platform) ? 'Meta' : 'Control'; |
There was a problem hiding this comment.
nothing sets platform, what's going on here
| await user.keyboard(`{${modifier}>}a{/${modifier}}`); | ||
|
|
||
| expect(onChange).toHaveBeenCalledTimes(1); | ||
| expect(onChange).toHaveBeenLastCalledWith(['cat', 'dog']); |
There was a problem hiding this comment.
all in our components is usually represented by "all", otherwise async loading selects would not be able to select all until every item has been loaded
|
Thanks for pointing this out. I converted 'all' to an array of loaded keys because multi-select Should I’ll revert the |
|
Well, I'm not sure we can use 'all' without it being a breaking change. People would need to check for it. But it's a bit unfortunate that it won't match and will need different handling so that async works for people. We can't "preserve 'all'" internally and expose it as array based, React controlled wouldn't work anymore. This will need some more opinions from the rest of the team |
|
Thanks for clarifying. Would selecting all currently loaded, enabled options be acceptable with the existing array-based API, with newly loaded options remaining unselected? I understand that differs from the other collection components. I’ll wait for the team’s input before revising the implementation. |
Closes #10958
Summary
In a Select with selectionMode="multiple", pressing Cmd/Ctrl+A or calling selectionManager.selectAll() leaves the selection unchanged. Both actions produce the 'all' selection value, which useSelectState previously discarded.
Following the approach proposed by the issue reporter, useSelectState converts 'all' to the keys of the enabled options and passes them through the existing selection update. Users can then deselect individual options after selecting all.
📝 Test Instructions
Release impact
✅ PR Checklist
I used ChatGPT to help investigate a issue
🧢 Your Project