question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When component is searchable, onBlur always resets value even when onBlurResetsInput is set to false

See original GitHub issue

Hi. 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:closed
  • Created 8 years ago
  • Reactions:12
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

21reactions
tiagoengelcommented, Apr 15, 2016

As a workaround, you can add onBlur={() => {}} or if you’re using redux-form onBlur={() => field.onBlur({value: field.value})}

9reactions
MilllerTimecommented, Sep 29, 2016

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!)

onBlur={() => input.onBlur(input.value)}

Link to doc for onBlur() signature.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found