Skip to content

Commit 4b6b563

Browse files
YoYuUmrisadams
authored andcommitted
simplify not blurring control when clicking on dropdown
Avoid control getting blurred on mousedown events on the dropdown Fixes selectize#1926
1 parent 544602b commit 4b6b563

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/selectize.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,15 @@ $.extend(Selectize.prototype, {
237237

238238
$document.on('mousedown' + eventNS, function(e) {
239239
if (self.isFocused) {
240-
// prevent events on the dropdown scrollbar from causing the control to blur
241-
if (e.target === self.$dropdown[0] || e.target.parentNode === self.$dropdown[0]) {
240+
// prevent events on the dropdown from causing the control to blur
241+
if (
242+
e.target === self.$dropdown[0] ||
243+
self.$dropdown.has(e.target).length)
244+
{
242245
return false;
243246
}
244247
// blur on click outside
245-
// do not blur if the dropdown is clicked
246-
if (self.$dropdown.has(e.target).length) {
247-
self.ignoreBlur = true;
248-
window.setTimeout(function() {
249-
self.ignoreBlur = false;
250-
}, 0);
251-
} else if (e.target !== self.$control[0]) {
248+
if (e.target !== self.$control[0]) {
252249
self.blur(e.target);
253250
}
254251
}
@@ -691,10 +688,6 @@ $.extend(Selectize.prototype, {
691688
onBlur: function(e, dest) {
692689
var self = this;
693690

694-
if (self.ignoreBlur) {
695-
return;
696-
}
697-
698691
if (!self.isFocused) return;
699692
self.isFocused = false;
700693

0 commit comments

Comments
 (0)