Skip to content

Commit 515a449

Browse files
committed
pull requests woocommerce#44 and woocommerce#45 are merged to our code base from upstream
1 parent dcb5be8 commit 515a449

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/js/select2/dropdown/search.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ define([
1818
this.$searchContainer = $search;
1919
this.$search = $search.find('input');
2020

21+
var label = this.options.get( 'label' );
22+
if ( typeof( label ) === 'string' ) {
23+
this.$search.attr( 'aria-label', label );
24+
}
25+
2126
$rendered.prepend($search);
2227

2328
return $rendered;

src/js/select2/selection/base.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ define([
1515
BaseSelection.prototype.render = function () {
1616
var $selection = $(
1717
'<span class="select2-selection" ' +
18-
' aria-haspopup="true" aria-expanded="false">' +
18+
' role="combobox" aria-haspopup="listbox" aria-expanded="false">' +
1919
'</span>'
2020
);
2121

@@ -60,10 +60,6 @@ define([
6060
}
6161
});
6262

63-
container.on('results:focus', function (params) {
64-
self.$selection.attr('aria-activedescendant', params.data._resultId);
65-
});
66-
6763
container.on('selection:update', function (params) {
6864
self.update(params.data);
6965
});
@@ -79,7 +75,6 @@ define([
7975
container.on('close', function () {
8076
// When the dropdown is closed, aria-expanded="false"
8177
self.$selection.attr('aria-expanded', 'false');
82-
self.$selection.removeAttr('aria-activedescendant');
8378
self.$selection.removeAttr('aria-owns');
8479

8580
// This needs to be delayed as the active element is the body when the

src/js/select2/selection/search.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ define([
1212
'<li class="select2-search select2-search--inline">' +
1313
'<input class="select2-search__field" type="text" tabindex="-1"' +
1414
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
15-
' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
15+
' spellcheck="false" role="textbox" aria-autocomplete="list"' +
16+
' aria-multiline="false" />' +
1617
'</li>'
1718
);
1819

1920
this.$searchContainer = $search;
2021
this.$search = $search.find('input');
2122

23+
var label = this.options.get( 'label' );
24+
if ( typeof( label ) === 'string' ) {
25+
this.$search.attr( 'aria-label', label );
26+
}
27+
2228
var $rendered = decorated.call(this);
2329

2430
this._transferTabIndex();
@@ -33,14 +39,14 @@ define([
3339
decorated.call(this, container, $container);
3440

3541
container.on('open', function () {
36-
self.$search.attr('aria-owns', resultsId);
42+
self.$search.attr('aria-controls', resultsId);
3743
self.$search.trigger('focus');
3844
});
3945

4046
container.on('close', function () {
4147
self.$search.val('');
4248
self.$search.removeAttr('aria-activedescendant');
43-
self.$search.removeAttr('aria-owns');
49+
self.$search.removeAttr('aria-controls');
4450
self.$search.trigger('focus');
4551
});
4652

0 commit comments

Comments
 (0)