JedWatson / react-select

The Select Component for React.js
https://react-select.com/
MIT License
27.42k stars 4.1k forks source link

Async multi select options are reset after selecting an option #5863

Closed mayank-permiso closed 4 months ago

mayank-permiso commented 4 months ago

Discussed in https://github.com/JedWatson/react-select/discussions/5862

Originally posted by **mayank-permiso** February 20, 2024 I'm using Async Select, and when I select an item it will keep the menu open and keep the search string (after implementing solution in https://github.com/JedWatson/react-select/issues/3210), but after selection of an option the options are reset to original results. ### For eg- I click on an AsyncSelect field, request goes and brings 10 results (lets call it as set A), now I type "aws" in the search field so the request again brings 10 new results (set B). Beautiful. But when I select an option from here, then these new options are replaced by Set A options. I need to change something in search field to see the Set B options again. CodeSandbox example- https://codesandbox.io/p/sandbox/codesandboxer-example-forked-krq7pn Type "re" and select an option, the list resets to original results. ### My current config- closeMenuOnSelect=false isMulti=true cacheOptions=true inputValue={input} // some state to hold current search string onInputChange={(value, action) => { if (action.action === "input-change") setInput(value); // <--- }} loadOptions= {loadOptions} // some function that is debounced and fetches new results with search string onChange, onBlur, value, name etc are there which are of not much importance for this issue I guess. Nothing seems to work. I searched a lot on net and did not find any configuration that can fix this. BTW, this behaviour is not seen with Normal Select component. Please help me on the same. Is this a legit bug or am I missing something here?
Krishna8691 commented 4 months ago

Not so sure but I think you are looking for the behavior that is mentioned in this comment - https://github.com/JedWatson/react-select/discussions/5862#discussioncomment-8672173 If it is what you were looking for then this thread can be closed.

mayank-permiso commented 4 months ago

This fulfils my need. Thank you for your input @Krishna8691. Closing the thread.