From 77e19fe64b89ff3de694294542b04bcba187b24c Mon Sep 17 00:00:00 2001 From: jlukic Date: Wed, 22 Oct 2014 13:26:02 -0400 Subject: [PATCH] Fix issue with search dropdown not working on menu click --- src/definitions/modules/dropdown.js | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index aac367974..304811289 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -77,9 +77,10 @@ $.fn.dropdown = function(parameters) { if(hasTouch) { module.bind.touchEvents(); } - module.observeChanges(); module.bind.mouseEvents(); module.bind.keyboardEvents(); + + module.observeChanges(); module.instantiate(); }, @@ -259,20 +260,6 @@ $.fn.dropdown = function(parameters) { .on(module.get.inputEvent(), selector.search, module.event.input) ; } - if( module.is.searchSelection() ) { - $module - .on('focus' + eventNamespace, selector.search, module.event.searchFocus) - .on('blur' + eventNamespace, selector.search, module.event.searchBlur) - ; - } - else { - $module - .on('mousedown', module.event.mousedown) - .on('mouseup', module.event.mouseup) - .on('focus' + eventNamespace, module.event.focus) - .on('blur' + eventNamespace, module.event.blur) - ; - } }, touchEvents: function() { module.debug('Touch device detected binding touch events'); @@ -288,7 +275,13 @@ $.fn.dropdown = function(parameters) { }, mouseEvents: function() { module.verbose('Mouse detected binding mouse events'); - if( !module.is.searchSelection() ) { + if( module.is.searchSelection() ) { + $module + .on('focus' + eventNamespace, selector.search, module.event.searchFocus) + .on('blur' + eventNamespace, selector.search, module.event.searchBlur) + ; + } + else { if(settings.on == 'click') { $module .on('click' + eventNamespace, module.event.test.toggle) @@ -305,6 +298,12 @@ $.fn.dropdown = function(parameters) { .on(settings.on + eventNamespace, module.toggle) ; } + $module + .on('mousedown', module.event.mousedown) + .on('mouseup', module.event.mouseup) + .on('focus' + eventNamespace, module.event.focus) + .on('blur' + eventNamespace, module.event.blur) + ; } $module .on('mouseenter' + eventNamespace, selector.item, module.event.item.mouseenter) @@ -409,7 +408,8 @@ $.fn.dropdown = function(parameters) { module.show(); }, searchBlur: function(event) { - module.hide(); + // give enough time for events to bubble + setTimeout(module.hide, 50); }, input: function(event) { var @@ -1338,7 +1338,7 @@ $.fn.dropdown.settings = { name : 'Dropdown', namespace : 'dropdown', - debug : false, + debug : true, verbose : true, performance : true,