Skip to content

Commit 0d6ba97

Browse files
committed
Update select2.js
jQuery("input#someId").attr("tabIndex") don't work well in new jQuery 1.8+. When you try this on field  that don't have tabIndex attr you get undefined (but document.getElementById("someId").tabIndex returns '0'). This is why Select2 element onBlur stay whit attr tabindex='-1' and you can't navigate form with 'tab' key. This simple ' || 0' fix this bug.
1 parent ac4ce8b commit 0d6ba97

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

select2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ the specific language governing permissions and limitations under the Apache Lic
15221522
if (!this.opened()) this.container.removeClass("select2-container-active");
15231523
window.setTimeout(this.bind(function() {
15241524
// restore original tab index
1525-
var ti=this.opts.element.attr("tabIndex");
1525+
var ti=this.opts.element.attr("tabIndex") || 0;
15261526
if (ti) {
15271527
this.selection.attr("tabIndex", ti);
15281528
} else {
@@ -1565,7 +1565,7 @@ the specific language governing permissions and limitations under the Apache Lic
15651565
if (!this.opened()) {
15661566
this.container.removeClass("select2-container-active");
15671567
}
1568-
window.setTimeout(this.bind(function() { this.search.attr("tabIndex", this.opts.element.attr("tabIndex")); }), 10);
1568+
window.setTimeout(this.bind(function() { this.search.attr("tabIndex", this.opts.element.attr("tabIndex") || 0); }), 10);
15691569
}));
15701570

15711571
selection.bind("keydown", this.bind(function(e) {

0 commit comments

Comments
 (0)