Create new option on blur with Creatable
See original GitHub issueFirst of of all, thanks for the great work on react-select
.
So, I needed to create a new option on blur with the Creatable
component, even if the the user didn’t executed one of the defaults triggers for the creation (e.g: click on"Create option ‘foo’", hit TAB or ENTER).
I was able to achieve this using refs and invoking createNewOption
in my parent component, something like this:
...
handleBlur(){
let { inputValue } = this.selector;
this.selector.createNewOption(inputValue)
}
render(){
<Creatable props={...this.props} onBlur={this.handleBlur} onBlurResetsInput={false}
ref={s => this.selector = s}/>
}
I’d like to know if there is any intention of adding a more intuitive support for this, like a createNewOptionOnBlur
prop for the Creatable
. I will be glad to open a PR if that’s the case.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:33
- Comments:19 (2 by maintainers)
Top Results From Across the Web
Selecting created option on menu close/select blur using ...
I have a list of e-mail addresses and want to allow user to select from the list or type new e-mail address and...
Read more >react-select: Keep input value on blur and menu close
CodeSandbox is an online editor tailored for web applications.
Read more >Creatable - React Select
A flexible and beautiful Select Input control for ReactJS with multiselect, autocomplete and ajax support.
Read more >Selecting created option on menu close/select blur using ...
Coding example for the question Selecting created option on menu close/select blur using creatable component-Reactjs.
Read more >React Select Example - Fully Customizable - YouTube
We will build React select with a single value, React multiselect with an ... menu will be also creatable to be able to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Plus one for this… would also use it
@sagar-ranglani
My mistake, I was blurring by tabbing out of the field which of course, selects the value. Here is an updated codesandbox based on your observations.
Codesandbox demo