Skip to content

Commit 84a54a5

Browse files
committed
fix(material/stepper): Adjust aria tab-related roles to fix violations
1 parent 5a1a0ba commit 84a54a5

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

src/material/stepper/step-header.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/privat
3636
'class': 'mat-step-header',
3737
'[class.mat-step-header-empty-label]': '_hasEmptyLabel()',
3838
'[class]': '"mat-" + (color || "primary")',
39-
'role': 'tab',
39+
'role': '',
4040
},
4141
encapsulation: ViewEncapsulation.None,
4242
changeDetection: ChangeDetectionStrategy.OnPush,

src/material/stepper/stepper.html

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@switch (orientation) {
1212
@case ('horizontal') {
1313
<div class="mat-horizontal-stepper-wrapper">
14-
<div class="mat-horizontal-stepper-header-container">
14+
<div class="mat-horizontal-stepper-header-container" role="tablist" aria-orientation="horizontal">
1515
@for (step of steps; track step) {
1616
<ng-container
1717
[ngTemplateOutlet]="stepTemplate"
@@ -40,28 +40,35 @@
4040
}
4141

4242
@case ('vertical') {
43-
@for (step of steps; track step) {
44-
<div class="mat-step">
45-
<ng-container
46-
[ngTemplateOutlet]="stepTemplate"
47-
[ngTemplateOutletContext]="{step}"/>
48-
<div
49-
#animatedContainer
50-
class="mat-vertical-content-container"
51-
[class.mat-stepper-vertical-line]="!$last"
52-
[class.mat-vertical-content-container-active]="selectedIndex === $index"
53-
[attr.inert]="selectedIndex === $index ? null : ''">
54-
<div class="mat-vertical-stepper-content"
55-
role="tabpanel"
56-
[id]="_getStepContentId($index)"
57-
[attr.aria-labelledby]="_getStepLabelId($index)">
58-
<div class="mat-vertical-content">
59-
<ng-container [ngTemplateOutlet]="step.content"/>
43+
<div class="mat-vertical-stepper-wrapper" role="tablist" aria-orientation="vertical">
44+
@for (step of steps; track step) {
45+
<div
46+
class="mat-step"
47+
role="tab"
48+
[attr.aria-posinset]="step.index() + 1"
49+
[attr.aria-setsize]="steps.length"
50+
[attr.aria-selected]="step.isSelected()"
51+
>
52+
<ng-container
53+
[ngTemplateOutlet]="stepTemplate"
54+
[ngTemplateOutletContext]="{step}"/>
55+
<div
56+
#animatedContainer
57+
class="mat-vertical-content-container"
58+
[class.mat-stepper-vertical-line]="!$last"
59+
[class.mat-vertical-content-container-active]="selectedIndex === $index"
60+
[attr.inert]="selectedIndex === $index ? null : ''">
61+
<div class="mat-vertical-stepper-content"
62+
[id]="_getStepContentId($index)"
63+
[attr.aria-labelledby]="_getStepLabelId($index)">
64+
<div class="mat-vertical-content">
65+
<ng-container [ngTemplateOutlet]="step.content"/>
66+
</div>
6067
</div>
6168
</div>
6269
</div>
63-
</div>
64-
}
70+
}
71+
</div>
6572
}
6673
}
6774

@@ -74,10 +81,11 @@
7481
(keydown)="_onKeydown($event)"
7582
[tabIndex]="_getFocusIndex() === step.index() ? 0 : -1"
7683
[id]="_getStepLabelId(step.index())"
77-
[attr.aria-posinset]="step.index() + 1"
78-
[attr.aria-setsize]="steps.length"
84+
[attr.role]="orientation === 'horizontal' ? 'tab' : null"
85+
[attr.aria-posinset]="orientation === 'horizontal' ? step.index() + 1 : null"
86+
[attr.aria-setsize]="orientation === 'horizontal' ? steps.length : null"
87+
[attr.aria-selected]="orientation === 'horizontal' ? step.isSelected() : null"
7988
[attr.aria-controls]="_getStepContentId(step.index())"
80-
[attr.aria-selected]="step.isSelected()"
8189
[attr.aria-label]="step.ariaLabel || null"
8290
[attr.aria-labelledby]="(!step.ariaLabel && step.ariaLabelledby) ? step.ariaLabelledby : null"
8391
[attr.aria-disabled]="step.isNavigable() ? null : true"

src/material/stepper/stepper.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ export class MatStep extends CdkStep implements ErrorStateMatcher, AfterContentI
130130
'[class.mat-stepper-header-position-bottom]': 'headerPosition === "bottom"',
131131
'[class.mat-stepper-animating]': '_isAnimating()',
132132
'[style.--mat-stepper-animation-duration]': '_getAnimationDuration()',
133-
'[attr.aria-orientation]': 'orientation',
134-
'role': 'tablist',
135133
},
136134
providers: [{provide: CdkStepper, useExisting: MatStepper}],
137135
encapsulation: ViewEncapsulation.None,

0 commit comments

Comments
 (0)