Skip to content

Commit 9c1caa6

Browse files
committed
add handling of autofocus attribute. fixes select2#837
1 parent 18c2bc5 commit 9c1caa6

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

select2.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,10 @@ the specific language governing permissions and limitations under the Apache Lic
736736

737737
// Calculate size of scrollbar
738738
scrollBarDimensions = scrollBarDimensions || measureScrollbar();
739+
740+
this.autofocus = opts.element.prop("autofocus")
741+
opts.element.prop("autofocus", false);
742+
if (this.autofocus) this.focus();
739743
},
740744

741745
// abstract
@@ -753,6 +757,7 @@ the specific language governing permissions and limitations under the Apache Lic
753757
.removeData("select2")
754758
.unbind(".select2")
755759
.attr({"tabindex": this.elementTabIndex})
760+
.prop("autofocus", this.autofocus)
756761
.show();
757762
}
758763
},
@@ -1886,6 +1891,7 @@ the specific language governing permissions and limitations under the Apache Lic
18861891
this.initContainerWidth();
18871892
this.opts.element.addClass("select2-offscreen");
18881893
this.setPlaceholder();
1894+
18891895
},
18901896

18911897
// single

0 commit comments

Comments
 (0)