Skip to content

Commit

Permalink
Add isBlurring flag for .blur and .close methods
Browse files Browse the repository at this point in the history
Fixes failing test after regression in selectize#1353, while
trying to preserve its functionality.
  • Loading branch information
joallard committed May 25, 2018
1 parent 51f1dd9 commit 8c76832
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var Selectize = function($input, settings) {

eventNS : '.selectize' + (++Selectize.count),
highlightedValue : null,
isBlurring : false,
isOpen : false,
isDisabled : false,
isRequired : $input.is('[required]'),
Expand Down Expand Up @@ -652,10 +653,12 @@ $.extend(Selectize.prototype, {
// IE11 bug: element still marked as active
dest && dest.focus && dest.focus();

self.isBlurring = false;
self.ignoreFocus = false;
self.trigger('blur');
};

self.isBlurring = true;
self.ignoreFocus = true;
if (self.settings.create && self.settings.createOnBlur) {
self.createItem(null, false, deactivate);
Expand Down Expand Up @@ -1783,7 +1786,7 @@ $.extend(Selectize.prototype, {
// Do not trigger blur while inside a blur event,
// this fixes some weird tabbing behavior in FF and IE.
// See #1164
if (self.ignoreFocus) {
if (!self.isBlurring) {
self.$control_input.blur(); // close keyboard on iOS
}
}
Expand Down

0 comments on commit 8c76832

Please sign in to comment.