@@ -102,6 +102,9 @@ var Typeahead = React.createClass({
102102 // Keep track of the focus state of the input element, to determine
103103 // whether to show options when empty (if showOptionsWhenEmpty is true)
104104 isFocused : false ,
105+
106+ // true when focused, false onOptionSelected
107+ showResults : false
105108 } ;
106109 } ,
107110
@@ -197,7 +200,8 @@ var Typeahead = React.createClass({
197200 nEntry . value = optionString ;
198201 this . setState ( { searchResults : this . getOptionsForValue ( optionString , this . props . options ) ,
199202 selection : formInputOptionString ,
200- entryValue : optionString } ) ;
203+ entryValue : optionString ,
204+ showResults : false } ) ;
201205 return this . props . onOptionSelected ( option , event ) ;
202206 } ,
203207
@@ -336,13 +340,13 @@ var Typeahead = React.createClass({
336340 onFocus = { this . _onFocus }
337341 onBlur = { this . _onBlur }
338342 />
339- { this . _renderIncrementalSearchResults ( ) }
343+ { this . state . showResults && this . _renderIncrementalSearchResults ( ) }
340344 </ div >
341345 ) ;
342346 } ,
343347
344348 _onFocus : function ( event ) {
345- this . setState ( { isFocused : true } , function ( ) {
349+ this . setState ( { isFocused : true , showResults : true } , function ( ) {
346350 this . _onTextEntryUpdated ( ) ;
347351 } . bind ( this ) ) ;
348352 if ( this . props . onFocus ) {
0 commit comments