Skip to content

Commit

Permalink
Fix dropdown closing on scroll bar click (selectize#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Veldhuizen committed Nov 14, 2016
1 parent 26d76cb commit 1480e9a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ var Selectize = function($input, settings) {
isCmdDown : false,
isCtrlDown : false,
ignoreFocus : false,
ignoreBlur : false,
ignoreHover : false,
hasOptions : false,
currentResults : null,
Expand Down Expand Up @@ -202,7 +201,7 @@ $.extend(Selectize.prototype, {
keypress : function() { return self.onKeyPress.apply(self, arguments); },
resize : function() { self.positionDropdown.apply(self, []); },
blur : function() { return self.onBlur.apply(self, arguments); },
focus : function() { self.ignoreBlur = false; return self.onFocus.apply(self, arguments); },
focus : function() { return self.onFocus.apply(self, arguments); },
paste : function() { return self.onPaste.apply(self, arguments); }
});

Expand All @@ -226,7 +225,7 @@ $.extend(Selectize.prototype, {
}
// blur on click outside
if (!self.$control.has(e.target).length && e.target !== self.$control[0]) {
self.blur(e.target);
self.close();
}
}
});
Expand Down Expand Up @@ -625,16 +624,22 @@ $.extend(Selectize.prototype, {
*/
onBlur: function(e, dest) {
var self = this;

if (document.activeElement === self.$dropdown_content[0]) {
// necessary to prevent IE closing the dropdown when the scrollbar is clicked
if (e) {
e.preventDefault();
e.stopImmediatePropagation();
}
self.onFocus(e);
return;
}

if (!self.isFocused) return;
self.isFocused = false;

if (self.ignoreFocus) {
return;
} else if (!self.ignoreBlur && document.activeElement === self.$dropdown_content[0]) {
// necessary to prevent IE closing the dropdown when the scrollbar is clicked
self.ignoreBlur = true;
self.onFocus(e);
return;
}

var deactivate = function() {
Expand Down

0 comments on commit 1480e9a

Please sign in to comment.