From 8520793f2517dbb2d102791faa9f4fe642fee39f Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Thu, 28 Feb 2013 19:47:03 -0800 Subject: [PATCH] workaround for chrome focus bug. fixes #939 --- select2.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/select2.js b/select2.js index f5f9084f..2ddbd2ba 100644 --- a/select2.js +++ b/select2.js @@ -1664,6 +1664,16 @@ the specific language governing permissions and limitations under the Apache Lic } })); + this.search.bind("blur", this.bind(function(e) { + // a workaround for chrome to keep the search field focussed when the scroll bar is used to scroll the dropdown. + // without this the search field loses focus which is annoying + if (document.activeElement === this.body().get(0)) { + window.setTimeout(this.bind(function() { + this.search.focus(); + }), 0); + } + })); + this.focusser.bind("keydown", this.bind(function (e) { if (!this.enabled) return;