Feature Request: Allow for sorting options in filterOptions prop #4426
Replies: 12 comments
-
Meanwhile i had to do something like this:
Hope it helps someone |
Beta Was this translation helpful? Give feedback.
-
It sounds like we need a companion function for
|
Beta Was this translation helpful? Give feedback.
-
@nenostra Thank you for your solution. It works pretty well. I didn't expect |
Beta Was this translation helpful? Give feedback.
-
Another issue with current |
Beta Was this translation helpful? Give feedback.
-
What about this theme? Any updates? |
Beta Was this translation helpful? Give feedback.
-
I'd love for this to become a first class part of the API |
Beta Was this translation helpful? Give feedback.
-
A new version slightly improved inspired in the version by @nenostra You can take this component and just use it instead of
|
Beta Was this translation helpful? Give feedback.
-
Greetings, I believe the solution proposed by @jossmac makes sense to encapsulate the changes to the
|
Beta Was this translation helpful? Give feedback.
-
Converted this from an issue to feature request for further discussion. |
Beta Was this translation helpful? Give feedback.
-
Any updates on supporting sorting option results? |
Beta Was this translation helpful? Give feedback.
-
any updates on this sorting option result feature? |
Beta Was this translation helpful? Give feedback.
-
@ebonow I think we should expose ranking each filter option instead of a boolean (show or hide) and then based on that ranking order the list. Also see https://github.com/orchidjs/sifter.js which is used by https://tom-select.js.org/
|
Beta Was this translation helpful? Give feedback.
-
In
v1
overriding the standardfilterOptions
meant that you could return theoptions
in a completely different order based on the search, whereas the newfilterOption
is only giving us the option to specify if that option should be shown or not.I think that having some way of ordering the results is useful in lots of cases. Here's one with some dummy data. Let's suppose that my options is a long list of names and we expect that someone will probably start typing the person's first name in order to get to that person as quickly as possible, but they might also only know a surname.
If we have the following names at the start of the options,
"Alexa Nabil"
,"Alexandra Bilani"
,"Bill Ward"
and the user starts typing"Bi"
then currently the default behaviour of react-select is to show the options in their original, alphabetical order, but I'd suggest that"Bill Ward"
,"Alexandra Bilani"
,"Alexa Nabil"
makes more sense once there's the user input. That's possible withfilterOptions
because you can sort the options at the same time as filtering them, but v2 leaves me without a way of doing this.Beta Was this translation helpful? Give feedback.
All reactions