Skip to content

fix: Ensure that combobox empty state is rendered when items arent directly provided to the combobox #8720

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

Merged
merged 2 commits into from
Aug 14, 2025

Conversation

LFDanLu
Copy link
Member

@LFDanLu LFDanLu commented Aug 13, 2025

Closes #8708

✅ 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 the RAC combobox async loading story and type in string that doesnt match (e.g. aaaaaaaa). "No Results" message should appear.

Try the same with the S2 async combobox as well

🧢 Your Project:

RSP

@rspbot
Copy link

rspbot commented Aug 13, 2025

Copy link
Member Author

@LFDanLu LFDanLu Aug 13, 2025

Choose a reason for hiding this comment

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

opted to add renderEmptyState in the reusable example, but that means there is a slight item height increase when typing in the async example and it renders the emptyState since that example doesn't use MyItem. If we are fine with that example getting the red hover style I can change that too

Copy link
Member

Choose a reason for hiding this comment

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

i think it's fine personally

@rspbot
Copy link

rspbot commented Aug 13, 2025

Copy link
Member Author

Choose a reason for hiding this comment

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

If the ComboBox either uses defaultItems or has its items defined by the wrapped ListBox, useComboBoxState will return a ListCollection instead of a BaseCollection, resulting in a different way of calculating collection size. The below change makes sure the loaders aren't included in the keymap which should be fine since they aren't focusable. Ideally, we'd always use a BaseCollection though

Copy link
Member

@reidbarber reidbarber left a comment

Choose a reason for hiding this comment

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

LGTM

@LFDanLu LFDanLu added this pull request to the merge queue Aug 14, 2025
Merged via the queue into main with commit c1a9b03 Aug 14, 2025
32 checks passed
@LFDanLu LFDanLu deleted the combobox_empty_state_fix branch August 14, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ComboBox with asynchronous loading doesn't render empty state when filtering
4 participants