Skip to content

Commit 9d19b7f

Browse files
committed
Redirect the focus of original input to Select2
Redirect the focus of original input to the "focus" event of Select2. this way, we get back the accessible label for feature of previous Select2 versions.
1 parent 3c17d3b commit 9d19b7f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

select2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,6 +2096,7 @@ the specific language governing permissions and limitations under the Apache Lic
20962096
this.focusser.attr("id", "s2id_autogen"+idSuffix);
20972097

20982098
elementLabel = $("label[for='" + this.opts.element.attr("id") + "']");
2099+
this.opts.element.focus(this.bind(function () { this.focus(); }));
20992100

21002101
this.focusser.prev()
21012102
.text(elementLabel.text())
@@ -2686,6 +2687,7 @@ the specific language governing permissions and limitations under the Apache Lic
26862687
this.search.prev()
26872688
.text($("label[for='" + this.opts.element.attr("id") + "']").text())
26882689
.attr('for', this.search.attr('id'));
2690+
this.opts.element.focus(this.bind(function () { this.focus(); }));
26892691

26902692
this.search.on("input paste", this.bind(function() {
26912693
if (this.search.attr('placeholder') && this.search.val().length == 0) return;

0 commit comments

Comments
 (0)