When component is searchable, onBlur always resets value even when onBlurResetsInput is set to false
See original GitHub issueHi. These are the options I’m using:
<Select
{...field}
value={field.value}
name={field.name}
searchable
onBlurResetsInput={false}
clearable={false}
className={"form-control"}
options={options}
/>
Though I’ve tried all sorts of combinations, and the only way I can get selected value to stick is to set searchable
to false. Otherwise, input resets when I click outside select.
Watching the state change, selecting option really does set value, and onBlur resets it.
Bug, or am I doing something wrong?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:12
- Comments:11 (1 by maintainers)
Top Results From Across the Web
onBlur resets value in react-select - Stack Overflow
When I type some text in searchable input and click outside, my text is disappear. I tried onBlur={() => input.onBlur({value: input.value})} and ...
Read more >Upgrade guide for v2 - React Select
React-select v2 is a complete rewrite, and includes some major changes: ... possible values: { action: 'set-value' | 'input-change' | 'input-blur' ...
Read more >react-select-text - npm
React-Select generates a hidden text field containing the selected value, so you can submit it as part of a standard form.
Read more >react-select/CHANGELOG.md - UNPKG
- [#3446](https://github.com/JedWatson/react-select/pull/3446) Fix bug with select input value not being selectable. Thanks [kangweichan](https://github.com/ ...
Read more >react-hook-form controlled input onblur doesn't work - You.com
In your code, the form mode is onBlur . it means the validation is triggered on blur event (unfocus the input). When you...
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
As a workaround, you can add
onBlur={() => {}}
or if you’re using redux-formonBlur={() => field.onBlur({value: field.value})}
Seems like this is still an issue.
@tiagoengel’s suggestion is a decent workaround. If you’re using redux-form v6, you’ll want to use the updated blur handler as follows (make sure you place it after you spread the redux-form
input
prop!)Link to doc for
onBlur()
signature.