Skip to content

Commit f16d0c7

Browse files
mpiotrowicztjvantoll
authored andcommitted
Accordion: moving aria-expanded from active tabpanel to active tab. Fixed #9407 - Accordion: aria-expanded attribute on wrong element
1 parent 7e68945 commit f16d0c7

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

tests/unit/accordion/accordion_core.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,29 @@ test( "accessibility", function () {
4646

4747
equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
4848
equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
49-
equal( headers.eq( 1 ).next().attr( "aria-expanded" ), "true", "active tabpanel has aria-expanded=true" );
49+
equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
5050
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" );
5151
equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
5252
equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
53-
equal( headers.eq( 0 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" );
53+
equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
5454
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
5555
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
5656
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
57-
equal( headers.eq( 2 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" );
57+
equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
5858
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
5959

6060
element.accordion( "option", "active", 0 );
6161
equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
6262
equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
63-
equal( headers.eq( 0 ).next().attr( "aria-expanded" ), "true", "active tabpanel has aria-expanded=true" );
63+
equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
6464
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" );
6565
equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
6666
equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
67-
equal( headers.eq( 1 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" );
67+
equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
6868
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
6969
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
7070
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
71-
equal( headers.eq( 2 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" );
71+
equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
7272
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
7373
});
7474

ui/jquery.ui.accordion.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ $.widget( "ui.accordion", {
109109
.removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
110110
"ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
111111
.removeAttr( "role" )
112+
.removeAttr( "aria-expanded" )
112113
.removeAttr( "aria-selected" )
113114
.removeAttr( "aria-controls" )
114115
.removeAttr( "tabIndex" )
@@ -122,7 +123,6 @@ $.widget( "ui.accordion", {
122123
"ui-accordion-content ui-accordion-content-active ui-state-disabled" )
123124
.css( "display", "" )
124125
.removeAttr( "role" )
125-
.removeAttr( "aria-expanded" )
126126
.removeAttr( "aria-hidden" )
127127
.removeAttr( "aria-labelledby" )
128128
.removeUniqueId();
@@ -288,11 +288,11 @@ $.widget( "ui.accordion", {
288288
.not( this.active )
289289
.attr({
290290
"aria-selected": "false",
291+
"aria-expanded": "false",
291292
tabIndex: -1
292293
})
293294
.next()
294295
.attr({
295-
"aria-expanded": "false",
296296
"aria-hidden": "true"
297297
})
298298
.hide();
@@ -303,11 +303,11 @@ $.widget( "ui.accordion", {
303303
} else {
304304
this.active.attr({
305305
"aria-selected": "true",
306+
"aria-expanded": "true",
306307
tabIndex: 0
307308
})
308309
.next()
309310
.attr({
310-
"aria-expanded": "true",
311311
"aria-hidden": "false"
312312
});
313313
}
@@ -462,15 +462,17 @@ $.widget( "ui.accordion", {
462462
}
463463

464464
toHide.attr({
465-
"aria-expanded": "false",
466465
"aria-hidden": "true"
467466
});
468467
toHide.prev().attr( "aria-selected", "false" );
469468
// if we're switching panels, remove the old header from the tab order
470469
// if we're opening from collapsed state, remove the previous header from the tab order
471470
// if we're collapsing, then keep the collapsing header in the tab order
472471
if ( toShow.length && toHide.length ) {
473-
toHide.prev().attr( "tabIndex", -1 );
472+
toHide.prev().attr({
473+
"tabIndex": -1,
474+
"aria-expanded": "false"
475+
});
474476
} else if ( toShow.length ) {
475477
this.headers.filter(function() {
476478
return $( this ).attr( "tabIndex" ) === 0;
@@ -479,14 +481,12 @@ $.widget( "ui.accordion", {
479481
}
480482

481483
toShow
482-
.attr({
483-
"aria-expanded": "true",
484-
"aria-hidden": "false"
485-
})
484+
.attr( "aria-hidden", "false" )
486485
.prev()
487486
.attr({
488487
"aria-selected": "true",
489-
tabIndex: 0
488+
tabIndex: 0,
489+
"aria-expanded": "true"
490490
});
491491
},
492492

@@ -558,7 +558,6 @@ $.widget( "ui.accordion", {
558558
if ( toHide.length ) {
559559
toHide.parent()[0].className = toHide.parent()[0].className;
560560
}
561-
562561
this._trigger( "activate", null, data );
563562
}
564563
});

0 commit comments

Comments
 (0)