Skip to content

Commit a59b3c7

Browse files
committed
Selectmenu: reset aria-activedescendant to selected item when menu is closed
1 parent 7c1a9d9 commit a59b3c7

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

ui/jquery.ui.selectmenu.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ $.widget( "ui.selectmenu", {
155155

156156
// Set ARIA active decendent
157157
that.button.attr( "aria-activedescendant", that.menuItems.eq( item.index ).find( "a" ).attr( "id" ) );
158-
159158
},
160159
// set ARIA role
161160
role: 'listbox'
@@ -233,6 +232,7 @@ $.widget( "ui.selectmenu", {
233232
if ( this.isOpen ) {
234233
this.isOpen = false;
235234
this._toggleAttr();
235+
this.button.attr( "aria-activedescendant", this._getSelectedItem().find( "a" ).attr( "id" ) );
236236
this._trigger( "close", event );
237237
}
238238
},
@@ -376,16 +376,12 @@ $.widget( "ui.selectmenu", {
376376
},
377377

378378
_setSelected: function( item ) {
379-
var itemId = this.menuItems.eq( item.index ).find( "a" ).attr( "id" );
380379
// update button text
381380
this.buttonText.html( item.label );
382381
// change ARIA attr
383382
this.menuItems.find( "a" ).attr( "aria-selected", false );
384383
this._getSelectedItem().find( "a" ).attr( "aria-selected", true );
385-
this.button.attr({
386-
"aria-activedescendant": itemId,
387-
"aria-labelledby": itemId
388-
});
384+
this.button.attr( "aria-labelledby", this.menuItems.eq( item.index ).find( "a" ).attr( "id" ) );
389385
},
390386

391387
_setOption: function( key, value ) {

0 commit comments

Comments
 (0)