I'm trying to validate a selection using react-bootstrap-typeahead and clear out the input text if invalid when I move to another area of the page.
I can't figure out a good way to do this.
The onBlur for the Typeahead component doesn't fire at the right time to validate and clear.
Any suggestions would be appreciated
Here is my typeahead definition
<Typeahead bsSize="sm"
defaultSelected = {this.props.options.slice(selectedIndex)}
clearButton
labelKey="roomNumber"
options={this.props.options}
placeholder={this.props.placeholder}
name={this.props.nameId}
ref={ref => this.roomChoice = ref}
onChange={this.onChangeHandler.bind(this)}
onInputChange={this.onInputChangeHandler.bind(this)}
onBlur={this.onBlurHandler.bind(this)}
onFocus={this.onFocusHandler.bind(this)}
/>
Here is my onBlur Function:
onBlurHandler(event)
{
if (this.roomInputText)
{
if (!this.roomSelectedOption)
{
this.roomChoice.getInstance().clear()
}
}
}
The onBlur isn't firing in the right time for me to have a selected option if someone entered text.