-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: add indexOf method for useFilter #7174
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR, you'll need to sign the CLA https://react-spectrum.adobe.com/contribute.html#contributor-license-agreement then you may need to close and reopen the PR to get it to take |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a reasonable request.
Giving a provisional approval and will bring up with the rest of the team.
Discussed with the team and the one concern we have is that it doesn't match the existing pattern of the filter functions which is to return a boolean. Do you mind sharing the use case you ended up needing this for? We may need something like this in the future, so it may help us figure out where it could fit in. |
@reidbarber Perhaps this is a In my case, there are some date and time options that need to be sorted by the first match position while being searched. The options that match earlier should be placed in front. |
Add indexOf method for useFilter.
I have met a situation where it is necessary to filter options by the index of a substring, so it would be better if an indexOf method could be provided directly.
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project:
Currently I am using the following as a workaround: