From 4094c1c7de62c223259e949ce1365cb800bde461 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Mon, 6 May 2013 19:42:38 -0700 Subject: [PATCH] fix tab-on-select transfers focus to next element. fixes #898. fixes #1045 --- select2.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/select2.js b/select2.js index 1a5665ba..56ace85d 100644 --- a/select2.js +++ b/select2.js @@ -1285,7 +1285,7 @@ the specific language governing permissions and limitations under the Apache Lic this.results.empty(); - this.clearSearch(); + this.clearSearch(); this.search.removeClass("select2-active"); this.opts.element.trigger($.Event("select2-close")); }, @@ -1729,7 +1729,7 @@ the specific language governing permissions and limitations under the Apache Lic if (!this.opened()) return; this.parent.close.apply(this, arguments); this.focusser.removeAttr("disabled"); - focus(this.focusser); + this.focusser.focus(); }, // single @@ -1791,11 +1791,13 @@ the specific language governing permissions and limitations under the Apache Lic this.moveHighlight((e.which === KEY.UP) ? -1 : 1); killEvent(e); return; - case KEY.TAB: case KEY.ENTER: this.selectHighlighted(); killEvent(e); return; + case KEY.TAB: + this.selectHighlighted({noFocus: true}); + return; case KEY.ESC: this.cancel(e); killEvent(e); @@ -2328,10 +2330,12 @@ the specific language governing permissions and limitations under the Apache Lic killEvent(e); return; case KEY.ENTER: - case KEY.TAB: this.selectHighlighted(); killEvent(e); return; + case KEY.TAB: + this.selectHighlighted({noFocus:true}); + return; case KEY.ESC: this.cancel(e); killEvent(e);