Skip to content

Commit 0cb3320

Browse files
committed
refactor(material/stepper): updates stepper to use same aria-roles pattern as vertical
Updates previous fix so that the aria-roles are cohesive between horizontal/vertical to simplify the patterns.
1 parent 54bab8e commit 0cb3320

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/cdk/stepper/step-header.ts

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import {FocusableOption} from '../a11y';
1111

1212
@Directive({
1313
selector: '[cdkStepHeader]',
14+
host: {
15+
'role': 'button',
16+
},
1417
})
1518
export class CdkStepHeader implements FocusableOption {
1619
_elementRef = inject<ElementRef<HTMLElement>>(ElementRef);

src/material/stepper/stepper.html

+6-9
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
@switch (orientation) {
1212
@case ('horizontal') {
13-
<div class="mat-horizontal-stepper-wrapper">
14-
<div class="mat-horizontal-stepper-header-container" role="tablist">
13+
<div class="mat-stepper-wrapper" role="group">
14+
<div class="mat-horizontal-stepper-header-container">
1515
@for (step of steps; track step) {
1616
<ng-container
1717
[ngTemplateOutlet]="stepTemplate"
@@ -27,7 +27,7 @@
2727
<div
2828
#animatedContainer
2929
class="mat-horizontal-stepper-content"
30-
role="tabpanel"
30+
role="region"
3131
[id]="_getStepContentId($index)"
3232
[attr.aria-labelledby]="_getStepLabelId($index)"
3333
[class]="'mat-horizontal-stepper-content-' + _getAnimationDirection($index)"
@@ -40,7 +40,7 @@
4040
}
4141

4242
@case ('vertical') {
43-
<div class="mat-vertical-stepper-wrapper" role="group">
43+
<div class="mat-stepper-wrapper" role="group">
4444
@for (step of steps; track step) {
4545
<div class="mat-step">
4646
<ng-container
@@ -72,16 +72,13 @@
7272
<mat-step-header
7373
[class.mat-horizontal-stepper-header]="orientation === 'horizontal'"
7474
[class.mat-vertical-stepper-header]="orientation === 'vertical'"
75-
[attr.role]="orientation === 'horizontal'? 'tab' : 'button'"
75+
role="button"
7676
(click)="step.select()"
7777
(keydown)="_onKeydown($event)"
7878
[tabIndex]="_getFocusIndex() === i ? 0 : -1"
7979
[id]="_getStepLabelId(i)"
80-
[attr.aria-posinset]="orientation === 'horizontal'? i + 1 : undefined"
81-
[attr.aria-setsize]="orientation === 'horizontal'? steps.length : undefined"
8280
[attr.aria-controls]="_getStepContentId(i)"
83-
[attr.aria-selected]="orientation === 'horizontal' ? selectedIndex == i : undefined"
84-
[attr.aria-expanded]="orientation === 'vertical' ? selectedIndex == i : undefined"
81+
[attr.aria-expanded]="selectedIndex == i"
8582
[attr.aria-label]="step.ariaLabel || null"
8683
[attr.aria-labelledby]="(!step.ariaLabel && step.ariaLabelledby) ? step.ariaLabelledby : null"
8784
[attr.aria-disabled]="_stepIsNavigable(i, step) ? null : true"

0 commit comments

Comments
 (0)