{"action":"closed","issue":{"url":"https://api.github.com/repos/brianreavis/selectize.js/issues/583","labels_url":"https://api.github.com/repos/brianreavis/selectize.js/issues/583/labels{/name}","comments_url":"https://api.github.com/repos/brianreavis/selectize.js/issues/583/comments","events_url":"https://api.github.com/repos/brianreavis/selectize.js/issues/583/events","html_url":"https://github.com/brianreavis/selectize.js/issues/583","id":44494025,"number":583,"title":"When selectize is disabled the onFocus event fires a blur event which resets focus to the document","user":{"login":"barretts","id":1238994,"avatar_url":"https://avatars.githubusercontent.com/u/1238994?v=3","gravatar_id":"","url":"https://api.github.com/users/barretts","html_url":"https://github.com/barretts","followers_url":"https://api.github.com/users/barretts/followers","following_url":"https://api.github.com/users/barretts/following{/other_user}","gists_url":"https://api.github.com/users/barretts/gists{/gist_id}","starred_url":"https://api.github.com/users/barretts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barretts/subscriptions","organizations_url":"https://api.github.com/users/barretts/orgs","repos_url":"https://api.github.com/users/barretts/repos","events_url":"https://api.github.com/users/barretts/events{/privacy}","received_events_url":"https://api.github.com/users/barretts/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2014-09-30T20:09:41Z","updated_at":"2015-01-30T02:20:33Z","closed_at":"2015-01-30T02:20:33Z","body":"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.\r\n\r\n```javascript\r\nif (self.isDisabled) {\r\n  self.blur();\r\n  e && e.preventDefault();\r\n  return false;\r\n}\r\n```\r\n\r\nI've made a plugin to circumvent this behavior but I thought it might be unintended as it breaks normal the normal flow of forms.\r\n\r\n```\r\nselectize.define('keep_focus_when_disabled', function() {\r\n  var self = this;\r\n\r\n  self.onFocus = (function() {\r\n    var original = self.onFocus;\r\n    return function(e) {\r\n      if (self.isDisabled) {\r\n        self.isFocused = true;\r\n        return;\r\n      }\r\n      original.apply(self, arguments);\r\n    };\r\n  })();\r\n});\r\n```"}}