React-select: Pass current value in `onBlur` event

Created on 30 Sep 2015  路  10Comments  路  Source: JedWatson/react-select

As discussed in erikras/redux-form#82

When you listen to the onBlur event on input fields, e.target.value will contain the value of the input which can be useful. This behaviour doesn't work in react-select because the DOM node being blurred is the search input, not the field itself.

We could hack around this and set e.target.value before firing the event handler - I'm not absolutely positive this would have no unintended side effects, but it seems safe.

Anyone want to weigh in on this?

categorquestion

Most helpful comment

causes problems with redux-form

All 10 comments

Related discussion was here #186

@JedWatson i might have a related issue here, if the user types in a search, but does not select it, it just completely types in the option then blurs the field, if what the user input completely matches one of the options, the select component should select that option and fire a change event. (at this time it will fire if the user tab's out, but not if the user clicks out from the component)

@JedWatson I have a similar issue. In my case, if the user has typed something but deselects the input, I'd like it to add that value to my multiselect. If a user presses tab, I would like it to also add the value and keep the input selected. For an example, check out how the compose view in Gmail works when you type someone's email in the "to" field.

I think there should be some configurability with respect to what happens when a user fails to select an option.

@JedWatson I use multiselect with redux-form and it expects data which is stored and propagated back to form. Could it be possible to add calling eg. onBlurValues?

I use wrapper component between redux-form and select component so I could map onBlur to onBlurValues.

So basically, onBlur should behave like any input and provide the current value. Can't think of any reason overwriting event.target.value is a problem, the events are syntetic events created by React to begin with.

Configurability of behavior could be done by adding methods (e.g. getCurrentOptions) to the Select class that are available via a ref to the component?

any new ideas here?

causes problems with redux-form

@JedWatson i am getting blank value in mobile browser in onBlur method. I am getting value of event.target.value in side onBlur method.
can anyone tell me the solution ?

@kumar91mahesh see this thread

Assuming resolved in v2. Bump if needs to be reopened.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

x-yuri picture x-yuri  路  3Comments

Meesam picture Meesam  路  3Comments

steida picture steida  路  3Comments

batusai513 picture batusai513  路  3Comments

coder-guy22296 picture coder-guy22296  路  3Comments