From 83c11b27dfedd455084f8ca2ccbe54894970190a Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Fri, 29 Jun 2012 22:38:34 -0700 Subject: [PATCH] fix firefox caret bug. closes #153 --- select2.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index d0f14b42..645c2041 100755 --- a/select2.js +++ b/select2.js @@ -476,7 +476,7 @@ installKeyUpChangeEvent(search); search.bind("keyup-change", this.bind(this.updateResults)); - search.bind("focus", function () { search.addClass("select2-focused");}); + search.bind("focus", function () { search.addClass("select2-focused"); search.val(""); }); search.bind("blur", function () { search.removeClass("select2-focused");}); this.dropdown.delegate(resultsSelector, "click", this.bind(function (e) { @@ -1527,7 +1527,9 @@ // stretch the search box to full width of the container so as much of the placeholder is visible as possible this.search.width(this.getContainerWidth()); } else { - this.search.val("").width(10); + // we set this to " " instead of "" and later clear it on focus() because there is a firefox bug + // that does not properly render the caret when the field starts out blank + this.search.val(" ").width(10); } },