How to remove focus once selected #4311
-
Probably this is a silly question but the default behavior of this amazing component is to keep the focus on the input once the user has done a selection the focus is kept to the input. I believe that this comes handy for many use cases but I would like to ignore accidental keypress that my user could make once selected. My understanding of the documentation about onChange={ ( item ) => {
this.setState( {
// updating state
} );
blur();
} } But this does not solve the problem because if I press some key on the keyboard the input shows that the I am sure that there is something wrong with my code but I can not understand where I should handle this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Greetings @AndreaBarghigiani , Have you tried the If you wanted to use the blur method programmatically instead, you would want to use a react ref like so: selectRef = react.createRef();
onChange= option => {
this.setState({});
selectRef.current.blur();
}
render () {
return <Select ref={this.selectRef} onChange={this.onChange} />
} |
Beta Was this translation helpful? Give feedback.
Greetings @AndreaBarghigiani ,
Have you tried the
blurInputOnSelect
prop as it sounds like what you are looking for?If you wanted to use the blur method programmatically instead, you would want to use a react ref like so: