From 6226b252abea74ce44c756f832f06c4ef26d8090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Magalha=CC=83es?= Date: Mon, 3 Aug 2015 10:46:06 +0100 Subject: [PATCH 1/2] only display options list if not empty --- src/typeahead/index.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/typeahead/index.js b/src/typeahead/index.js index 0e220edb..e07326b1 100644 --- a/src/typeahead/index.js +++ b/src/typeahead/index.js @@ -139,16 +139,18 @@ var Typeahead = React.createClass({ return ""; } - return ( - - ); + if (this.state.visible.length || this._getCustomValue()) { + return ( + + ); + } }, getSelection: function() { From 06f9362a30bbcdb34092eef69ead67d8d188187a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Magalha=CC=83es?= Date: Fri, 11 Mar 2016 15:02:48 +0000 Subject: [PATCH 2/2] move logic to _shouldSkipSearch method --- src/typeahead/index.js | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/typeahead/index.js b/src/typeahead/index.js index 5ab4a134..4f88e5a4 100644 --- a/src/typeahead/index.js +++ b/src/typeahead/index.js @@ -97,8 +97,16 @@ var Typeahead = React.createClass({ }, _shouldSkipSearch: function(input) { - var emptyValue = !input || input.trim().length == 0; - return !this.props.showOptionsWhenEmpty && emptyValue; + var result; + + if (this.state.visible.length || this._getCustomValue()) { + result = true; + } else { + var emptyValue = !input || input.trim().length == 0; + result = !this.props.showOptionsWhenEmpty && emptyValue; + } + + return result; }, getOptionsForValue: function(value, options) { @@ -148,18 +156,16 @@ var Typeahead = React.createClass({ return ""; } - if (this.state.visible.length || this._getCustomValue()) { - return ( - - ); - } + return ( + + ); }, getSelection: function() {