@@ -161,8 +161,7 @@ $.extend(Selectize.prototype, {
161
161
self . $dropdown_content = $dropdown_content ;
162
162
163
163
$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 ) ; } ) ;
166
165
watchChildEvent ( $control , 'mousedown' , '*:not(input)' , function ( ) { return self . onItemSelect . apply ( self , arguments ) ; } ) ;
167
166
autoGrow ( $control_input ) ;
168
167
@@ -202,7 +201,7 @@ $.extend(Selectize.prototype, {
202
201
}
203
202
// blur on click outside
204
203
if ( ! self . $control . has ( e . target ) . length && e . target !== self . $control [ 0 ] ) {
205
- self . blur ( ) ;
204
+ self . blur ( e . target ) ;
206
205
}
207
206
}
208
207
} ) ;
@@ -590,17 +589,17 @@ $.extend(Selectize.prototype, {
590
589
* Triggered on <input> blur.
591
590
*
592
591
* @param {object } e
592
+ * @param {Element } dest
593
593
*/
594
- onBlur : function ( e ) {
594
+ onBlur : function ( e , dest ) {
595
595
var self = this ;
596
- var wasFocused = self . isFocused ;
596
+ if ( ! self . isFocused ) return ;
597
+ self . isFocused = false ;
597
598
598
599
if ( self . ignoreFocus ) {
599
- self . isFocused = false ;
600
600
return ;
601
601
} else if ( ! self . ignoreBlur && document . activeElement === self . $dropdown_content [ 0 ] ) {
602
602
// necessary to prevent IE closing the dropdown when the scrollbar is clicked
603
- self . isFocused = false ;
604
603
self . ignoreBlur = true ;
605
604
self . onFocus ( e ) ;
606
605
return ;
@@ -615,14 +614,13 @@ $.extend(Selectize.prototype, {
615
614
self . refreshState ( ) ;
616
615
617
616
// IE11 bug: element still marked as active
618
- document . body . focus ( ) ;
617
+ ( dest || document . body ) . focus ( ) ;
619
618
620
619
self . ignoreFocus = false ;
621
- if ( wasFocused ) self . trigger ( 'blur' ) ;
620
+ self . trigger ( 'blur' ) ;
622
621
} ;
623
622
624
623
self . ignoreFocus = true ;
625
- self . isFocused = false ;
626
624
if ( self . settings . create && self . settings . createOnBlur ) {
627
625
self . createItem ( null , false , deactivate ) ;
628
626
} else {
@@ -915,9 +913,12 @@ $.extend(Selectize.prototype, {
915
913
916
914
/**
917
915
* Forces the control out of focus.
916
+ *
917
+ * @param {Element } dest
918
918
*/
919
- blur : function ( ) {
920
- this . $control_input . blur ( ) ;
919
+ blur : function ( dest ) {
920
+ this . $control_input [ 0 ] . blur ( ) ;
921
+ this . onBlur ( null , dest ) ;
921
922
} ,
922
923
923
924
/**
0 commit comments