diff --git a/docs/usage.md b/docs/usage.md
index cfd02589f..3b89900d4 100644
--- a/docs/usage.md
+++ b/docs/usage.md
@@ -141,6 +141,12 @@ $(function() {
boolean |
false |
+
+ closeDropdownThreshold |
+ The number of milliseconds to throttle the opening of the dropdown after it is closed by clicking on the control. Setting this to 0 will reopen the dropdown after clicking on the control when the dropdown is open. This does not affect multi-selects. |
+ int |
+ 250 |
+
allowEmptyOption |
If true, Selectize will treat any options with a "" value like normal. This defaults to false to accomodate the common <select> practice of having the first empty option to act as a placeholder. |
diff --git a/src/defaults.js b/src/defaults.js
index 49ad336b4..67733cc1a 100644
--- a/src/defaults.js
+++ b/src/defaults.js
@@ -24,6 +24,7 @@ Selectize.defaults = {
showEmptyOptionInDropdown: false,
emptyOptionLabel: '--',
closeAfterSelect: false,
+ closeDropdownThreshold: 250, // number of ms to prevent reopening of dropdown after mousedown
scrollDuration: 60,
deselectBehavior: 'previous', //top, previous
diff --git a/src/selectize.js b/src/selectize.js
index a2fd9dbb4..428d87d2b 100644
--- a/src/selectize.js
+++ b/src/selectize.js
@@ -41,6 +41,7 @@ var Selectize = function($input, settings) {
caretPos : 0,
loading : 0,
loadedSearches : {},
+ isDropdownClosing: false,
$activeOption : null,
$activeItems : [],
@@ -368,6 +369,12 @@ $.extend(Selectize.prototype, {
onClick: function(e) {
var self = this;
+ // if the dropdown is closing due to a mousedown, we don't want to
+ // refocus the element.
+ if (self.isDropdownClosing) {
+ return;
+ }
+
// necessary for mobile webkit devices (manual focus triggering
// is ignored unless invoked within a click event)
// also necessary to reopen a dropdown that has been closed by
@@ -398,6 +405,15 @@ $.extend(Selectize.prototype, {
if (self.settings.mode === 'single') {
// toggle dropdown
self.isOpen ? self.close() : self.open();
+
+ // when closing the dropdown, we set a isDropdownClosing
+ // varible temporaily to prevent the dropdown from reopening
+ // from the onClick event
+ self.isDropdownClosing = true;
+ setTimeout(function() {
+ self.isDropdownClosing = false;
+ }, self.settings.closeDropdownThreshold);
+
} else if (!defaultPrevented) {
self.setActiveItem(null);
}