-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Issue #1689, change selectize behavior to work inside modals. #1813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,7 +135,7 @@ $.extend(Selectize.prototype, { | |
|
||
$wrapper = $('<div>').addClass(settings.wrapperClass).addClass(classes).addClass(inputMode); | ||
$control = $('<div>').addClass(settings.inputClass).addClass('items').appendTo($wrapper); | ||
$control_input = $('<input type="text" autocomplete="new-password" autofill="no" />').appendTo($control).attr('tabindex', $input.is(':disabled') ? '-1' : self.tabIndex); | ||
$control_input = $('<input type="select-one" autocomplete="new-password" autofill="no" />').appendTo($control).attr('tabindex', $input.is(':disabled') ? '-1' : self.tabIndex); | ||
$dropdown_parent = $(settings.dropdownParent || $wrapper); | ||
$dropdown = $('<div>').addClass(settings.dropdownClass).addClass(inputMode).hide().appendTo($dropdown_parent); | ||
$dropdown_content = $('<div>').addClass(settings.dropdownContentClass).attr('tabindex', '-1').appendTo($dropdown); | ||
|
@@ -190,10 +190,10 @@ $.extend(Selectize.prototype, { | |
self.$dropdown = $dropdown; | ||
self.$dropdown_content = $dropdown_content; | ||
|
||
$dropdown.on('mouseenter mousedown click', '[data-disabled]>[data-selectable]', function(e) { e.stopImmediatePropagation(); }); | ||
$dropdown.on('mouseenter mousedown mouseup click', '[data-disabled]>[data-selectable]', function(e) { e.stopImmediatePropagation(); }); | ||
$dropdown.on('mouseenter', '[data-selectable]', function() { return self.onOptionHover.apply(self, arguments); }); | ||
$dropdown.on('mousedown click', '[data-selectable]', function() { return self.onOptionSelect.apply(self, arguments); }); | ||
watchChildEvent($control, 'mousedown', '*:not(input)', function() { return self.onItemSelect.apply(self, arguments); }); | ||
$dropdown.on('mouseup click', '[data-selectable]', function() { return self.onOptionSelect.apply(self, arguments); }); | ||
watchChildEvent($control, 'mouseup', '*:not(input)', function() { return self.onItemSelect.apply(self, arguments); }); | ||
autoGrow($control_input); | ||
|
||
$control.on({ | ||
|
@@ -207,7 +207,7 @@ $.extend(Selectize.prototype, { | |
keypress : function() { return self.onKeyPress.apply(self, arguments); }, | ||
input : function() { return self.onInput.apply(self, arguments); }, | ||
resize : function() { self.positionDropdown.apply(self, []); }, | ||
blur : function() { return self.onBlur.apply(self, arguments); }, | ||
// blur : function() { return self.onBlur.apply(self, arguments); }, | ||
focus : function() { self.ignoreBlur = false; return self.onFocus.apply(self, arguments); }, | ||
paste : function() { return self.onPaste.apply(self, arguments); } | ||
}); | ||
|
@@ -231,7 +231,8 @@ $.extend(Selectize.prototype, { | |
return false; | ||
} | ||
// blur on click outside | ||
if (!self.$control.has(e.target).length && e.target !== self.$control[0]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $control will never have e.target here, as e.target is contained within $dropdown. This appears to be a logic error. When clicking inside of the dropdown we do not want to blur, so $dropdown.has(e.target) is the correct logic here. |
||
// do not blur if the dropdown is clicked | ||
if (!self.$dropdown.has(e.target).length && e.target !== self.$control[0]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
self.blur(e.target); | ||
} | ||
} | ||
|
@@ -648,12 +649,14 @@ $.extend(Selectize.prototype, { | |
|
||
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; | ||
} | ||
// Bug fix do not blur dropdown here | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code causes the drop down to flash open then closed when a click is detected outside of the control. Let's remove it - nobody uses IE11 any more. |
||
// 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() { | ||
self.close(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Native selects change on the mouse-up. Selectize should match this behavior.