Skip to content

Commit

Permalink
#2842, Calling show results does not require input to be focused
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Aug 13, 2015
1 parent 643a330 commit d649872
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 28 additions & 23 deletions src/definitions/modules/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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() ) {
Expand Down

0 comments on commit d649872

Please sign in to comment.