From ccf830a6009bcf4a629b72ae9bf8d1971ab86781 Mon Sep 17 00:00:00 2001 From: jlukic Date: Mon, 12 Jan 2015 17:49:39 -0500 Subject: [PATCH] Fix bug with search input inside dropdown --- src/definitions/modules/dropdown.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index c1f44a541..fe023fcac 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -138,12 +138,9 @@ $.fn.dropdown = function(parameters) { query = $search.val(); module.verbose('Searching for query', query); - - if(module.is.searchSelection()) { - module.filter(query); - if( module.can.show() ) { - module.show(); - } + module.filter(query); + if(module.is.searchSelection() && module.can.show() ) { + module.show(); } }, @@ -405,7 +402,9 @@ $.fn.dropdown = function(parameters) { ; if( module.is.allFiltered() ) { module.debug('All items filtered, hiding dropdown', searchTerm); - module.hide(); + if(module.is.searchSelection()) { + module.hide(); + } settings.onNoResults.call(element, searchTerm); } }, @@ -452,7 +451,9 @@ $.fn.dropdown = function(parameters) { } }, input: function(event) { - module.set.filtered(); + if(module.is.searchSelection()) { + module.set.filtered(); + } clearTimeout(module.timer); module.timer = setTimeout(module.search, settings.delay.search); }, @@ -753,8 +754,8 @@ $.fn.dropdown = function(parameters) { return ($choice.data(metadata.text) !== undefined) ? $choice.data(metadata.text) : (preserveHTML) - ? $choice.html() - : $choice.text() + ? $choice.html().trim() + : $choice.text().trim() ; } }, @@ -763,8 +764,8 @@ $.fn.dropdown = function(parameters) { return ($choice.data(metadata.value) !== undefined) ? $choice.data(metadata.value) : (typeof choiceText === 'string') - ? choiceText.toLowerCase() - : choiceText + ? choiceText.toLowerCase().trim() + : choiceText.trim() ; }, inputEvent: function() {