react-typeahead
react-typeahead copied to clipboard
After selecting an option, typehead doesn't work until blur and refocus
Same issue on my end.
This fixed it for me, i added this to my onOptionSelect callback:
this.refs.typeahead.setEntryText('');
this.refs.typeahead.setState({ showResults: true })
I fixed it by doing a manual blur
/focus
on the input, which is horrible 😕
Same issue - fixed thanks to @zikphil
You can also use an onchange event and the typeahead as a ref similar to @zikphil
if (this.typeahead.state.showResults !== true) {
this.typeahead.setState({ showResults: true });
}
does anyone know if there is a fix to this? i have tried @zikphil's method and it didnt work...
@Richard-Thompson have you tried my workaround?
I'm not using the tokeniser version just the other standard typeahead version, so Im not sure how to integrate that into my code base. Here is my code for the typeahead:
<Typeahead
defaultValue='o'
ref='typeahead'
options={this.props.playlists}
filterOption='songTitle'
maxVisible={10}
displayOption={(option) => {
return option.songTitle;
}}
onOptionSelected={(option)=> {
this.refs.typeahead.setEntryText('');
browserHistory.push(`/playlist/${option.playlistTitle}`);
}}
customClasses={{
input: "topcoat-text-input",
results: "results-container",
hover: "result-active"
}}
className={`${this.props.screenSize} form-control mr-sm-2`}
/>
in onOptionSelected
, adding this.refs.typeahead.refs.entry.blur() ; this.refs.typeahead.refs.entry.focus()
should work
all im getting is
maybe the package has changed this this fix was stated?
ah, sorry, typo. it should be this.refs.typeahead.refs.entry.blur()
(same for focus as well)
Thanks, this has worked, I was so close to using .entry wasn't too sure. Anyway thanks for the help!