diff --git a/select2.css b/select2.css
index 0544120d..859c0c39 100755
--- a/select2.css
+++ b/select2.css
@@ -468,4 +468,6 @@ disabled look for already selected choices in the results dropdown
}
/* end multiselect */
-.select2-match { text-decoration: underline; }
\ No newline at end of file
+.select2-match { text-decoration: underline; }
+
+.select2-offscreen { position: absolute; left: -1000px; }
\ No newline at end of file
diff --git a/select2.js b/select2.js
index c41286a4..43dd1781 100755
--- a/select2.js
+++ b/select2.js
@@ -1022,7 +1022,7 @@
"class": "select2-container",
"style": "width: " + this.getContainerWidth()
}).html([
- " ",
+ " ",
" ",
"
" ,
"",
@@ -1075,7 +1075,8 @@
dropdown = this.dropdown,
containers = $([this.container.get(0), this.dropdown.get(0)]),
clickingInside = false,
- selector = ".select2-choice";
+ selector = ".select2-choice",
+ focusser=container.find("input.select2-focusser");
this.selection = selection = container.find(selector);
@@ -1126,9 +1127,10 @@
}
}));
containers.delegate(selector, "focus", function () { if (this.enabled) { containers.addClass("select2-container-active"); dropdown.addClass("select2-drop-active"); }});
- containers.delegate(selector, "blur", this.bind(function () {
+ containers.delegate(selector, "blur", this.bind(function (e) {
if (clickingInside) return;
- if (!this.opened()) this.blur();
+ if (e.target===focusser.get(0)) return; // ignore blurs from focusser
+ if (!this.opened()) { this.blur(); }
}));
selection.delegate("abbr", "click", this.bind(function (e) {
@@ -1137,9 +1139,18 @@
killEvent(e);
this.close();
this.triggerChange();
+ selection.focus();
}));
this.setPlaceholder();
+
+ focusser.bind("focus", function() { selection.focus(); });
+ selection.bind("focus", this.bind(function() {
+ focusser.hide();
+ this.container.addClass("select2-container-active");
+ }));
+ selection.bind("blur", function() { focusser.show(); });
+ this.opts.element.bind("open", function() { focusser.hide(); });
},
/**