Skip to content

Commit

Permalink
Merge pull request #203 from pebblecode/feature/hide-show-results
Browse files Browse the repository at this point in the history
Feature/hide show results
  • Loading branch information
fmoo committed Jun 1, 2016
2 parents 61fa555 + 6cc4422 commit 4ef4274
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/typeahead/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ var Typeahead = React.createClass({
// Keep track of the focus state of the input element, to determine
// whether to show options when empty (if showOptionsWhenEmpty is true)
isFocused: false,

// true when focused, false onOptionSelected
showResults: false
};
},

Expand Down Expand Up @@ -197,7 +200,8 @@ var Typeahead = React.createClass({
nEntry.value = optionString;
this.setState({searchResults: this.getOptionsForValue(optionString, this.props.options),
selection: formInputOptionString,
entryValue: optionString});
entryValue: optionString,
showResults: false});
return this.props.onOptionSelected(option, event);
},

Expand Down Expand Up @@ -336,13 +340,13 @@ var Typeahead = React.createClass({
onFocus={this._onFocus}
onBlur={this._onBlur}
/>
{ this._renderIncrementalSearchResults() }
{ this.state.showResults && this._renderIncrementalSearchResults() }
</div>
);
},

_onFocus: function(event) {
this.setState({isFocused: true}, function () {
this.setState({isFocused: true, showResults: true}, function () {
this._onTextEntryUpdated();
}.bind(this));
if ( this.props.onFocus ) {
Expand Down

0 comments on commit 4ef4274

Please sign in to comment.