Skip to content

Commit

Permalink
Fixes auto-selection of first entry on mount.
Browse files Browse the repository at this point in the history
  • Loading branch information
visusnet committed Jul 25, 2018
1 parent 8de72b6 commit 5870dde
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Typeahead.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,12 @@ export default class Typeahead extends PureComponent<Props, State> {
const {autoSelectSingleOption, options} = this.props;
if (autoSelectSingleOption && options.length === 1) {
const valueOfSingleOption = options[0].value;
this.setState({
highlightedIndex: 0,
value: valueOfSingleOption,
typedLabel: Typeahead._getLabelByValue(valueOfSingleOption, this.props.options,
this.props.allowUnknownValue)
});
this._fireOnChange(valueOfSingleOption);
}

Expand Down

0 comments on commit 5870dde

Please sign in to comment.