Skip to content

Commit 6a48cda

Browse files
committed
Accordion: Make sure there's always one header with tabindex=0. Fixes #8348 - Accordion: Collapsed accordion is removed from tab order.
1 parent 1af21ce commit 6a48cda

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

ui/jquery.ui.accordion.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -453,16 +453,23 @@ $.widget( "ui.accordion", {
453453
this._toggleComplete( data );
454454
}
455455

456-
toHide
457-
.attr({
458-
"aria-expanded": "false",
459-
"aria-hidden": "true"
456+
toHide.attr({
457+
"aria-expanded": "false",
458+
"aria-hidden": "true"
459+
});
460+
toHide.prev().attr( "aria-selected", "false" );
461+
// if we're switching panels, remove the old header from the tab order
462+
// if we're opening from collapsed state, remove the previous header from the tab order
463+
// if we're collapsing, then keep the collapsing header in the tab order
464+
if ( toShow.length && toHide.length ) {
465+
toHide.prev().attr( "tabIndex", -1 );
466+
} else if ( toShow.length ) {
467+
this.headers.filter(function() {
468+
return $( this ).attr( "tabIndex" ) === 0;
460469
})
461-
.prev()
462-
.attr({
463-
"aria-selected": "false",
464-
tabIndex: -1
465-
});
470+
.attr( "tabIndex", -1 );
471+
}
472+
466473
toShow
467474
.attr({
468475
"aria-expanded": "true",

0 commit comments

Comments
 (0)