Skip to content

fix(SelectionManager): support full collection for select all functionality#9621

Open
reidbarber wants to merge 6 commits intomainfrom
selectionmanager-fullcollection
Open

fix(SelectionManager): support full collection for select all functionality#9621
reidbarber wants to merge 6 commits intomainfrom
selectionmanager-fullcollection

Conversation

@reidbarber
Copy link
Member

@reidbarber reidbarber commented Feb 6, 2026

Closes #9620

When you had a collection with 'all' selected inside an Autocomplete, then filtered down the collection and toggled an item, the 'all' selection internally was only including filtered items' keys, so you'd lose selection for all non-visible items.

This adds a fullCollection field so we can still access the unfiltered collection when toggling selection.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Test new story:

  1. Filter down the list by typing 'ba'
  2. De-select one of the options
  3. Clear the field
  4. 'Foo' should still be selected
Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

This seems to work well for fixed collections, but what do you think about async loaded items or if the wrapped collection has controlled items (i.e. the filtering is handled externally and items constantly changes causing fullCollection to change)? I suppose for that case it would reasonable to expect selected keys to be tracked outside the component itself?

@snowystinger
Copy link
Member

(i.e. the filtering is handled externally and items constantly changes causing fullCollection to change)?

I think it'd be good to have some tests for some of these. It'd help me to reason about it.

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

I think the current behavior should be fine, since as mentioned previously it would be best for Autocompletes with controlled items (aka fetching a list of items or performing server side filtering) to have their selection controlled and tracked by the user/app.

@github-actions github-actions bot added the RAC label Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment