Skip to content

Commit ce67f7b

Browse files
committed
fix select2#1426 - reinitting screws up tabindex
1 parent 779b4ba commit ce67f7b

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

select2.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -763,21 +763,24 @@ the specific language governing permissions and limitations under the Apache Lic
763763

764764
// abstract
765765
destroy: function () {
766-
var select2 = this.opts.element.data("select2");
766+
var element=this.opts.element, select2 = element.data("select2");
767767

768768
if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; }
769769

770770
if (select2 !== undefined) {
771-
772771
select2.container.remove();
773772
select2.dropdown.remove();
774-
select2.opts.element
773+
element
775774
.removeClass("select2-offscreen")
776775
.removeData("select2")
777776
.off(".select2")
778-
.attr({"tabindex": this.elementTabIndex})
779-
.prop("autofocus", this.autofocus||false)
780-
.show();
777+
.prop("autofocus", this.autofocus || false);
778+
if (this.elementTabIndex) {
779+
element.attr({tabindex: this.elementTabIndex});
780+
} else {
781+
element.removeAttr("tabindex");
782+
}
783+
element.show();
781784
}
782785
},
783786

0 commit comments

Comments
 (0)