Skip to content

Fix select all in multi-select Select - #10977

Open
Bhavani2016 wants to merge 2 commits into
adobe:mainfrom
Bhavani2016:fix/select-all-10958
Open

Bhavani2016 wants to merge 2 commits into
adobe:mainfrom
Bhavani2016:fix/select-all-10958

Conversation

@Bhavani2016

Copy link
Copy Markdown
Contributor

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

  • Ran yarn test packages/react-aria-components/test/Select.test.js on the PR branch. All 40 tests passed.
  • The keyboard regression test failed before the fix because onChange received zero calls. It passed after the fix and confirmed that only the enabled options were selected.
  • The programmatic regression test confirmed that selectionManager.selectAll() selects the enabled options and that deselecting Cat leaves Dog selected. This test was verified after the fix.
  • Manually checked Cmd+A in local Storybook with selectionMode set to multiple on macOS. Ctrl+A was not manually tested on Windows or Linux.

Release impact

  • Only changes docs, tests, CI, or development tools. Nothing shipped to users changes.
  • Fixes a bug or improves existing code without changing how apps use it.
  • Adds a feature or API while keeping existing usage working.
  • May break existing usage or require changes in apps that use this code.

✅ PR Checklist

  • I followed the contributing guide.
  • I tested this change locally and included the results in Test Instructions, or explained why testing does not apply.
  • I understand and can explain every change in this PR. If I used AI assistance, I followed the AI contribution guidance.

I used ChatGPT to help investigate a issue

🧢 Your Project

@snowystinger

Copy link
Copy Markdown
Member

You're failing lint

@Bhavani2016

Copy link
Copy Markdown
Contributor Author

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({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this moved?

export function useListState<T>(props: ListProps<T>): ListState<T> {
export function useListState<T>(
props: ListProps<T>,
onSelectionChange?: (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing sets platform, what's going on here

await user.keyboard(`{${modifier}>}a{/${modifier}}`);

expect(onChange).toHaveBeenCalledTimes(1);
expect(onChange).toHaveBeenLastCalledWith(['cat', 'dog']);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Bhavani2016

Copy link
Copy Markdown
Contributor Author

Thanks for pointing this out. I converted 'all' to an array of loaded keys because multi-select Select currently uses a Key[] value. That loses the select-all intent for items loaded later.

Should Select preserve 'all' internally while keeping its public value and onChange array-based, or should the public API also support 'all'? That affects what a controlled Select should report when the user selects all and then deselects one item.

I’ll revert the useListState signature change, remove the stale comment, and make the keyboard test set the platform explicitly.

@snowystinger

Copy link
Copy Markdown
Member

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

@Bhavani2016

Copy link
Copy Markdown
Contributor Author

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.

@snowystinger snowystinger added the needs decision Needs team input label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs decision Needs team input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select with selectionMode="multiple" ignores selectAll() and Cmd/Ctrl+A

2 participants