Skip to content

How to make onSelectResetsInput example works with non-multi react select? #4384

Discussion options

You must be logged in to vote

Greetings @MohammedSaberMohammed ,

In the following Discussion thread #4341 highlighting previous codesandbox examples developed for the community, you will find an example which allows a user to retain the inputValue.

https://codesandbox.io/s/react-select-editable-and-selectable-6nfdv

Please note the behavior is designed to clear out input when the input is blurred.

    // onBlur => setInputValue to last selected value
    if (action === "input-blur") {
      setInputValue(value ? value.label : "");
    }

If you would like to retain whatever text was entered, you can replace the empty string assignment with inputValue

I hope this is helpful and let me know if you have questions about the…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@MohammedSaberMohammed
Comment options

@ebonow
Comment options

@ebonow
Comment options

@MohammedSaberMohammed
Comment options

Answer selected by ebonow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants