@@ -161,8 +161,7 @@ $.extend(Selectize.prototype, {
161161 self . $dropdown_content = $dropdown_content ;
162162
163163 $dropdown . on ( 'mouseenter' , '[data-selectable]' , function ( ) { return self . onOptionHover . apply ( self , arguments ) ; } ) ;
164- $dropdown . on ( 'mousedown' , '[data-selectable]' , function ( ) { return self . onOptionSelect . apply ( self , arguments ) ; } ) ;
165- $dropdown . on ( 'click' , '[data-selectable]' , function ( ) { return self . onOptionSelect . apply ( self , arguments ) ; } ) ;
164+ $dropdown . on ( 'mousedown click' , '[data-selectable]' , function ( ) { return self . onOptionSelect . apply ( self , arguments ) ; } ) ;
166165 watchChildEvent ( $control , 'mousedown' , '*:not(input)' , function ( ) { return self . onItemSelect . apply ( self , arguments ) ; } ) ;
167166 autoGrow ( $control_input ) ;
168167
@@ -202,7 +201,7 @@ $.extend(Selectize.prototype, {
202201 }
203202 // blur on click outside
204203 if ( ! self . $control . has ( e . target ) . length && e . target !== self . $control [ 0 ] ) {
205- self . blur ( ) ;
204+ self . blur ( e . target ) ;
206205 }
207206 }
208207 } ) ;
@@ -590,17 +589,17 @@ $.extend(Selectize.prototype, {
590589 * Triggered on <input> blur.
591590 *
592591 * @param {object } e
592+ * @param {Element } dest
593593 */
594- onBlur : function ( e ) {
594+ onBlur : function ( e , dest ) {
595595 var self = this ;
596- var wasFocused = self . isFocused ;
596+ if ( ! self . isFocused ) return ;
597+ self . isFocused = false ;
597598
598599 if ( self . ignoreFocus ) {
599- self . isFocused = false ;
600600 return ;
601601 } else if ( ! self . ignoreBlur && document . activeElement === self . $dropdown_content [ 0 ] ) {
602602 // necessary to prevent IE closing the dropdown when the scrollbar is clicked
603- self . isFocused = false ;
604603 self . ignoreBlur = true ;
605604 self . onFocus ( e ) ;
606605 return ;
@@ -615,14 +614,13 @@ $.extend(Selectize.prototype, {
615614 self . refreshState ( ) ;
616615
617616 // IE11 bug: element still marked as active
618- document . body . focus ( ) ;
617+ ( dest || document . body ) . focus ( ) ;
619618
620619 self . ignoreFocus = false ;
621- if ( wasFocused ) self . trigger ( 'blur' ) ;
620+ self . trigger ( 'blur' ) ;
622621 } ;
623622
624623 self . ignoreFocus = true ;
625- self . isFocused = false ;
626624 if ( self . settings . create && self . settings . createOnBlur ) {
627625 self . createItem ( null , false , deactivate ) ;
628626 } else {
@@ -915,9 +913,12 @@ $.extend(Selectize.prototype, {
915913
916914 /**
917915 * Forces the control out of focus.
916+ *
917+ * @param {Element } dest
918918 */
919- blur : function ( ) {
920- this . $control_input . blur ( ) ;
919+ blur : function ( dest ) {
920+ this . $control_input [ 0 ] . blur ( ) ;
921+ this . onBlur ( null , dest ) ;
921922 } ,
922923
923924 /**
0 commit comments