A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/selectize/selectize.js/issues/583 below:

When selectize is disabled the onFocus event fires a blur event which resets focus to the document · Issue #583 · selectize/selectize.js · GitHub

In the onFocus function of selectize.js the blur function is called if the selectize control isDisabled variabled is true. This becomes a problem when you place a selectized element in a form. When you tab to a disabled selectize element the blur is called and moves the users focus to the document start, taking them out of the form they were filling in. This action prevents the user from being able to tab to the next element in the form.

if (self.isDisabled) {
  self.blur();
  e && e.preventDefault();
  return false;
}

I've made a plugin to circumvent this behavior but I thought it might be unintended as it breaks normal the normal flow of forms.

selectize.define('keep_focus_when_disabled', function() {
  var self = this;

  self.onFocus = (function() {
    var original = self.onFocus;
    return function(e) {
      if (self.isDisabled) {
        self.isFocused = true;
        return;
      }
      original.apply(self, arguments);
    };
  })();
});

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4