Skip to content

Commit 056cab8

Browse files
committed
Accordion: set aria-selected to true on selected header, false on others. Fixed #7078 - Accordion: Set aria-selected
1 parent 84257e7 commit 056cab8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

tests/unit/accordion/accordion_core.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test( "ui-accordion-heading class added to headers anchor", function() {
2828
});
2929

3030
test( "accessibility", function () {
31-
expect( 9 );
31+
expect( 13 );
3232
var ac = $( "#list1" ).accordion().accordion( "option", "active", 1 );
3333
var headers = $( ".ui-accordion-header" );
3434

@@ -39,9 +39,13 @@ test( "accessibility", function () {
3939
equals( headers.next().attr( "role" ), "tabpanel", "tabpanel roles" );
4040
equals( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded" );
4141
equals( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded" );
42+
equals( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
43+
equals( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
4244
ac.accordion( "option", "active", 0 );
4345
equals( headers.eq( 0 ).attr( "aria-expanded" ), "true", "newly active tab has aria-expanded" );
4446
equals( headers.eq( 1 ).attr( "aria-expanded" ), "false", "newly inactive tab has aria-expanded" );
47+
equals( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
48+
equals( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
4549
});
4650

4751
}( jQuery ) );

ui/jquery.ui.accordion.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ $.widget( "ui.accordion", {
7575
.not( self.active )
7676
.attr({
7777
"aria-expanded": "false",
78+
"aria-selected": "false",
7879
tabIndex: -1
7980
})
8081
.next()
@@ -87,6 +88,7 @@ $.widget( "ui.accordion", {
8788
self.active
8889
.attr({
8990
"aria-expanded": "true",
91+
"aria-selected": "true",
9092
tabIndex: 0
9193
});
9294
}
@@ -129,6 +131,7 @@ $.widget( "ui.accordion", {
129131
.removeClass( "ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
130132
.removeAttr( "role" )
131133
.removeAttr( "aria-expanded" )
134+
.removeAttr( "aria-selected" )
132135
.removeAttr( "tabIndex" )
133136
.find( "a" )
134137
.removeAttr( "tabIndex" )
@@ -387,12 +390,14 @@ $.widget( "ui.accordion", {
387390
toHide.prev()
388391
.attr({
389392
"aria-expanded": "false",
393+
"aria-selected": "false",
390394
tabIndex: -1
391395
})
392396
.blur();
393397
toShow.prev()
394398
.attr({
395399
"aria-expanded": "true",
400+
"aria-selected": "true",
396401
tabIndex: 0
397402
})
398403
.focus();

0 commit comments

Comments
 (0)