Browse Source

#3856 #3870 - Fixed issue where onSelect event would not prevent bubbled close event on blur.

pull/3763/merge
Jack Lukic 8 years ago
parent
commit
21d24a087c
2 changed files with 15 additions and 2 deletions
  1. 1
      RELEASE-NOTES.md
  2. 16
      src/definitions/modules/search.js

1
RELEASE-NOTES.md

@ -36,6 +36,7 @@
- **Form Validation** - Revalidating a field `on: blur` could cause fields not yet interacted with to be validated #3606
- **Rail** - Fixed incorrect width for `close rail` and `very close rail` caused by variable addition with mixed units `px` + `em` #3835
- **Search** - A previous unfinished XHR query aborting would cause the next query to fail #2779
- **Search** - Fixed an issue where `onResult` returning `false` would not prevent the search menu from hiding. Clicking on an empty results message will also no longer close the search results. #3856 #3870
- **Video** - Fixed issue with `change` behavior not working properly when correctly to change videos.
**Bugs**

16
src/definitions/modules/search.js

@ -61,6 +61,8 @@ $.fn.search = function(parameters) {
element = this,
instance = $module.data(moduleNamespace),
disabledBubbled = false,
module
;
@ -168,8 +170,13 @@ $.fn.search = function(parameters) {
if(module.resultsClicked) {
module.debug('Determining if user action caused search to close');
$module
.one('click', selector.results, function(event) {
if( !module.is.animating() && !module.is.hidden() ) {
.one('click.close' + eventNamespace, selector.results, function(event) {
if(module.is.inMessage(event) || disabledBubbled) {
$prompt.focus();
return;
}
disabledBubbled = false;
if( !module.is.animating() && !module.is.hidden()) {
callback();
}
})
@ -209,6 +216,7 @@ $.fn.search = function(parameters) {
if( $.isFunction(settings.onSelect) ) {
if(settings.onSelect.call(element, result, results) === false) {
module.debug('Custom onSelect callback cancelled default select action');
disabledBubbled = true;
return;
}
}
@ -356,6 +364,9 @@ $.fn.search = function(parameters) {
hidden: function() {
return $results.hasClass(className.hidden);
},
inMessage: function(event) {
return (event.target && $(event.target).closest(selector.message).length > 0);
},
empty: function() {
return ($results.html() === '');
},
@ -1223,6 +1234,7 @@ $.fn.search.settings = {
prompt : '.prompt',
searchButton : '.search.button',
results : '.results',
message : '.results > .message',
category : '.category',
result : '.result',
title : '.title, .name'

Loading…
Cancel
Save