-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Make ListBox filter directly overridable #8084
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
Comments
@vezaynk While I believe this feature is already on the roadmap and just waiting for |
@nwidynski Would you accept outside contributions for this? This isn't a burning feature for us, but I'm interested in opportunities to dig into react-spectrum internals. |
Wouldn't
Break the rules of hooks, can't call it conditionally, and calling it multiple times? |
@snowystinger After sleeping on it, it doesn't look like a great pattern regardless. It was just one of the things that I tried. |
well, TIL, haven't gotten the chance to use |
Last note, I've actually found what I was looking for within defaultItems={allDropdownOptions}
defaultFilter={(textValue, filter) => {
const option = findItemByLabel(allDropdownOptions, textValue);
if (option) {
const { value, label } = option;
return contains(value, filter) || contains(label, filter);
}
return false;
}} |
With regards to |
Provide a general summary of the feature here
It would be nice if the filtering here could be override directly on the
ListBox
declaratively. LikeRight now, to achieve custom filtering, you need to setup the combox as a controlled component: https://react-spectrum.adobe.com/react-aria/useComboBox.html#custom-filtering
And then repeat the items you want in the context on both the Listbox and Combox. This introduces local state where you don't need to have it.
I'd be happy to make the PR if the team is okay with it
Alternatively, I can also see a solution where the
filter
is overridable on Combobox itself.Another solution that I would enjoy seeing, would be enabling this pattern:
This work require being able to simply toggle the filtering on/off.
🤔 Expected Behavior?
Custom filtering on Comboboxes should not require local state
😯 Current Behavior
Custom filtering on Comboboxes requires local state
💁 Possible Solution
All a
filter
prop onListbox
OR on components that provide the filter currently (e.g.Combobox
)🔦 Context
I had to introduce local state because I wanted the filtering to react to the aria-label and some invisible metadata. I felt as though I was breaking a pattern by introducing local state.
💻 Examples
No response
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
The text was updated successfully, but these errors were encountered: