-
Notifications
You must be signed in to change notification settings - Fork 4.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
Manually filter select options #372
Comments
I see two ways, both pretty hacky, sorry. (I've not tested either of them, so apologies if they don't work) Option 1: Option 2: hacky hacky mchack I think the real answer is to add a public API method, so people can officially call "refreshOptions", or some such, which filters again, possibly refreshing via async if needed. For a select-box chain like this, I can definitely see the use case, and should be pretty trivial to implement. Let me know if either of the above options work, and I'll try and see if I can create a PR to add a public API method (no guarantee it'll be accepted obviously - not sure if that's something that's on the radar). |
@bruderstein the Option1 works! But I've had to put it in I've not tested the Option 2, do you want me to do that? Anyway, it seems, as you said, a lot hacky, because you are mixing Also, the public API seems great to me, and, as you said, it should be simple to make this kind of select-box chain (even using async to do the job). Thank you for your quick and great answer! |
Great, at least you've got a solution for now. Leave option 2, I think option 1 is slightly less hacky, and should be easy to change to an official API if it's accepted. |
@bruderstein @wmartins I would also like to set up a "controlled" select box where one select box's options array is filtered based on the value of another select box. I am currently loading options externally so I am not using the asyncOptions prop. Is there some other recommended way for me to tell a select box to "re-filter" options? |
Version 1 of react-select is no longer supported. In the best interest of the community we've decided to spend the time we have available on the latest version. We apologise for any inconvenience. Please see: |
Hi, I have two selects on the same page, lets call them
SelectA
andSelectB
for explanation purposes.The
SelectB
has some options that may be filtered bySelectA
(both of them areasyncOptions
).SelectB
has afilterOptions
prop, that do the filter based on option selected bySelectA
, but how can I make this "communication" between both selects?I just need a simple way to "say" to
SelectB
filter its options again.Any ideas on that? Thank you!
The text was updated successfully, but these errors were encountered: