Skip to content

Commit eb187f4

Browse files
committed
tweaks
1 parent d2a6417 commit eb187f4

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
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': '',
39+
'role': '', // ignore cdk role in favor of setting appropriately in html
4040
},
4141
encapsulation: ViewEncapsulation.None,
4242
changeDetection: ChangeDetectionStrategy.OnPush,

src/material/stepper/stepper.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
@switch (orientation) {
1212
@case ('horizontal') {
1313
<div class="mat-horizontal-stepper-wrapper">
14-
<div class="mat-horizontal-stepper-header-container" role="tablist" aria-orientation="horizontal">
14+
<div
15+
aria-orientation="horizontal"
16+
class="mat-horizontal-stepper-header-container"
17+
role="tablist">
1518
@for (step of steps; track step) {
1619
<ng-container
1720
[ngTemplateOutlet]="stepTemplate"
@@ -40,7 +43,10 @@
4043
}
4144

4245
@case ('vertical') {
43-
<div class="mat-vertical-stepper-wrapper" role="tablist" aria-orientation="vertical">
46+
<div
47+
aria-orientation="vertical"
48+
class="mat-vertical-stepper-wrapper"
49+
role="tablist">
4450
@for (step of steps; track step) {
4551
<div
4652
class="mat-step"

src/material/stepper/stepper.spec.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ describe('MatStepper', () => {
114114
expect(stepper.selected instanceof MatStep).toBe(true);
115115
});
116116

117-
it('should set the "tablist" role on stepper', () => {
118-
const stepperEl = fixture.debugElement.query(By.css('mat-stepper'))!.nativeElement;
119-
expect(stepperEl.getAttribute('role')).toBe('tablist');
120-
});
121-
122117
it('should display the correct label', () => {
123118
let selectedLabel = fixture.nativeElement.querySelector('[aria-selected="true"]');
124119
expect(selectedLabel.textContent).toMatch('Step 1');
@@ -344,7 +339,7 @@ describe('MatStepper', () => {
344339

345340
it('should set the correct aria-posinset and aria-setsize', () => {
346341
const headers = Array.from<HTMLElement>(
347-
fixture.nativeElement.querySelectorAll('.mat-step-header'),
342+
fixture.nativeElement.querySelectorAll('[role="tab"]'),
348343
);
349344

350345
expect(headers.map(header => header.getAttribute('aria-posinset'))).toEqual(['1', '2', '3']);
@@ -941,7 +936,7 @@ describe('MatStepper', () => {
941936
const fixture = createComponent(SimpleMatVerticalStepperApp);
942937
fixture.detectChanges();
943938

944-
const stepperEl = fixture.debugElement.query(By.css('mat-stepper'))!.nativeElement;
939+
const stepperEl = fixture.debugElement.query(By.css('[role="tablist"]'))!.nativeElement;
945940
expect(stepperEl.getAttribute('aria-orientation')).toBe('vertical');
946941
});
947942

@@ -1045,7 +1040,7 @@ describe('MatStepper', () => {
10451040
const fixture = createComponent(SimpleMatHorizontalStepperApp);
10461041
fixture.detectChanges();
10471042

1048-
const stepperEl = fixture.debugElement.query(By.css('mat-stepper'))!.nativeElement;
1043+
const stepperEl = fixture.debugElement.query(By.css('[role="tablist"]'))!.nativeElement;
10491044
expect(stepperEl.getAttribute('aria-orientation')).toBe('horizontal');
10501045
});
10511046

0 commit comments

Comments
 (0)