Browse Source

#2842, Calling show results does not require input to be focused

pull/2850/head
jlukic 9 years ago
parent
commit
d6498722ec
2 changed files with 29 additions and 23 deletions
  1. 1
      RELEASE-NOTES.md
  2. 51
      src/definitions/modules/search.js

1
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

51
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() ) {

Loading…
Cancel
Save