From d6498722ec262ac467bc75152c767de271edf4a6 Mon Sep 17 00:00:00 2001 From: jlukic Date: Thu, 13 Aug 2015 17:29:20 -0400 Subject: [PATCH] #2842, Calling show results does not require input to be focused --- RELEASE-NOTES.md | 1 + src/definitions/modules/search.js | 51 +++++++++++++++++-------------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 519b1b8234..55d95b17d7 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -63,6 +63,7 @@ - **Modal** - Fix autofocus setting in modal not working due to improper selector #2737 - **Modal** - Increased `close` specificity, modal will now only close on `> .close` #2736 - **Transition** - Transition callbacks now all have the correct `this` set. #2758 +- **Search** - Calling `show results` programmatically no longer fails when input is not focused #2842 **[Community Bug Fixes](https://github.com/Semantic-Org/Semantic-UI/issues?q=is%3Aissue+milestone%3A2.1.0+is%3Aclosed)** - **API** - API debug is now `false` by default, like other modules. #2817 diff --git a/src/definitions/modules/search.js b/src/definitions/modules/search.js index f427b36c89..a5dbf9017c 100644 --- a/src/definitions/modules/search.js +++ b/src/definitions/modules/search.js @@ -126,7 +126,9 @@ $.fn.search = function(parameters) { module.set.focus(); if( module.has.minimumCharacters() ) { module.query(); - module.showResults(); + if( module.can.show() ) { + module.showResults(); + } } }, blur: function(event) { @@ -288,6 +290,9 @@ $.fn.search = function(parameters) { useAPI: function() { return $.fn.api !== undefined; }, + show: function() { + return !module.is.visible() && module.is.focused() && !module.is.empty(); + }, transition: function() { return settings.transition && $.fn.transition !== undefined && $module.transition('is supported'); } @@ -752,32 +757,32 @@ $.fn.search = function(parameters) { $results .html(html) ; - module.showResults(); + if( module.can.show() ) { + module.showResults(); + } }, showResults: function() { - if( !module.is.visible() && module.is.focused() && !module.is.empty() ) { - if( module.can.transition() ) { - module.debug('Showing results with css animations'); - $results - .transition({ - animation : settings.transition + ' in', - debug : settings.debug, - verbose : settings.verbose, - duration : settings.duration, - queue : true - }) - ; - } - else { - module.debug('Showing results with javascript'); - $results - .stop() - .fadeIn(settings.duration, settings.easing) - ; - } - settings.onResultsOpen.call($results); + if( module.can.transition() ) { + module.debug('Showing results with css animations'); + $results + .transition({ + animation : settings.transition + ' in', + debug : settings.debug, + verbose : settings.verbose, + duration : settings.duration, + queue : true + }) + ; + } + else { + module.debug('Showing results with javascript'); + $results + .stop() + .fadeIn(settings.duration, settings.easing) + ; } + settings.onResultsOpen.call($results); }, hideResults: function() { if( module.is.visible() ) {