-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cdk/accordion): improve accessibility in example code (#30087)
Updated the example code for the CDK accordion component to address accessibility issues resolves #30041 (cherry picked from commit de6c491)
- Loading branch information
Showing
2 changed files
with
30 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 23 additions & 23 deletions
46
...ponents-examples/cdk/accordion/cdk-accordion-overview/cdk-accordion-overview-example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
<cdk-accordion class="example-accordion"> | ||
@for (item of items; track item; let index = $index) { | ||
<cdk-accordion-item | ||
|
||
#accordionItem="cdkAccordionItem" | ||
class="example-accordion-item" | ||
role="button" | ||
<cdk-accordion-item #accordionItem="cdkAccordionItem" class="example-accordion-item"> | ||
<button | ||
class="example-accordion-item-header" | ||
(click)="accordionItem.toggle()" | ||
tabindex="0" | ||
[attr.id]="'accordion-header-' + index" | ||
[attr.aria-expanded]="accordionItem.expanded" | ||
[attr.aria-controls]="'accordion-body-' + index"> | ||
<div class="example-accordion-item-header" (click)="accordionItem.toggle()"> | ||
{{ item }} | ||
<span class="example-accordion-item-description"> | ||
Click to {{ accordionItem.expanded ? 'close' : 'open' }} | ||
</span> | ||
</div> | ||
<div | ||
class="example-accordion-item-body" | ||
role="region" | ||
[style.display]="accordionItem.expanded ? '' : 'none'" | ||
[attr.id]="'accordion-body-' + index" | ||
[attr.aria-labelledby]="'accordion-header-' + index"> | ||
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Perferendis | ||
excepturi incidunt ipsum deleniti labore, tempore non nam doloribus blanditiis | ||
veritatis illo autem iure aliquid ullam rem tenetur deserunt velit culpa? | ||
</div> | ||
</cdk-accordion-item> | ||
{{ item }} | ||
<span class="example-accordion-item-description"> | ||
Click to {{ accordionItem.expanded ? 'close' : 'open' }} | ||
</span> | ||
</button> | ||
@if(accordionItem.expanded) { | ||
<div | ||
class="example-accordion-item-body" | ||
role="region" | ||
[style.display]="accordionItem.expanded ? '' : 'none'" | ||
[attr.id]="'accordion-body-' + index" | ||
[attr.aria-labelledby]="'accordion-header-' + index" | ||
> | ||
Lorem ipsum dolor, sit amet, consectetur adipisicing elit. Perferendis excepturi incidunt ipsum | ||
deleniti labore, tempore non nam doloribus blanditiis veritatis illo autem iure aliquid ullam | ||
rem tenetur deserunt velit culpa? | ||
</div> | ||
} | ||
</cdk-accordion-item> | ||
} | ||
</cdk-accordion> | ||
|