Skip to content

Commit 7abb5a2

Browse files
committed
tweak
1 parent b984662 commit 7abb5a2

File tree

2 files changed

+18
-31
lines changed

2 files changed

+18
-31
lines changed

src/material/stepper/stepper.html

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,9 @@
4343
}
4444

4545
@case ('vertical') {
46-
<div
47-
aria-orientation="vertical"
48-
class="mat-vertical-stepper-wrapper"
49-
role="tablist">
46+
<div class="mat-vertical-stepper-wrapper">
5047
@for (step of steps; track step) {
51-
<div
52-
class="mat-step"
53-
role="tab"
54-
[attr.aria-posinset]="step.index() + 1"
55-
[attr.aria-setsize]="steps.length"
56-
[attr.aria-selected]="step.isSelected()"
57-
>
48+
<div class="mat-step">
5849
<ng-container
5950
[ngTemplateOutlet]="stepTemplate"
6051
[ngTemplateOutletContext]="{step}"/>
@@ -91,6 +82,7 @@
9182
[attr.aria-posinset]="orientation === 'horizontal' ? step.index() + 1 : null"
9283
[attr.aria-setsize]="orientation === 'horizontal' ? steps.length : null"
9384
[attr.aria-selected]="orientation === 'horizontal' ? step.isSelected() : null"
85+
[attr.aria-current]="orientation === 'vertical' && step.isSelected() ? 'step' : null"
9486
[attr.aria-controls]="_getStepContentId(step.index())"
9587
[attr.aria-label]="step.ariaLabel || null"
9688
[attr.aria-labelledby]="(!step.ariaLabel && step.ariaLabelledby) ? step.ariaLabelledby : null"

src/material/stepper/stepper.spec.ts

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,19 @@ describe('MatStepper', () => {
115115
});
116116

117117
it('should display the correct label', () => {
118-
let selectedLabel = fixture.nativeElement.querySelector('[aria-selected="true"]');
118+
let selectedLabel = fixture.nativeElement.querySelector('[aria-current="step"]');
119119
expect(selectedLabel.textContent).toMatch('Step 1');
120120

121121
fixture.componentInstance.stepper.selectedIndex = 2;
122122
fixture.detectChanges();
123123

124-
selectedLabel = fixture.nativeElement.querySelector('[aria-selected="true"]');
124+
selectedLabel = fixture.nativeElement.querySelector('[aria-current="step"]');
125125
expect(selectedLabel.textContent).toMatch('Step 3');
126126

127127
fixture.componentInstance.inputLabel.set('New Label');
128128
fixture.detectChanges();
129129

130-
selectedLabel = fixture.nativeElement.querySelector('[aria-selected="true"]');
130+
selectedLabel = fixture.nativeElement.querySelector('[aria-current="step"]');
131131
expect(selectedLabel.textContent).toMatch('New Label');
132132
});
133133

@@ -337,15 +337,6 @@ describe('MatStepper', () => {
337337
animationDoneSubscription.unsubscribe();
338338
});
339339

340-
it('should set the correct aria-posinset and aria-setsize', () => {
341-
const headers = Array.from<HTMLElement>(
342-
fixture.nativeElement.querySelectorAll('[role="tab"]'),
343-
);
344-
345-
expect(headers.map(header => header.getAttribute('aria-posinset'))).toEqual(['1', '2', '3']);
346-
expect(headers.every(header => header.getAttribute('aria-setsize') === '3')).toBe(true);
347-
});
348-
349340
it('should adjust the index when removing a step before the current one', () => {
350341
const stepper = fixture.componentInstance.stepper;
351342

@@ -932,14 +923,6 @@ describe('MatStepper', () => {
932923
});
933924

934925
describe('vertical stepper', () => {
935-
it('should set the aria-orientation to "vertical"', () => {
936-
const fixture = createComponent(SimpleMatVerticalStepperApp);
937-
fixture.detectChanges();
938-
939-
const stepperEl = fixture.debugElement.query(By.css('[role="tablist"]'))!.nativeElement;
940-
expect(stepperEl.getAttribute('aria-orientation')).toBe('vertical');
941-
});
942-
943926
it('should support using the left/right arrows to move focus', () => {
944927
const fixture = createComponent(SimpleMatVerticalStepperApp);
945928
fixture.detectChanges();
@@ -1061,6 +1044,18 @@ describe('MatStepper', () => {
10611044
assertArrowKeyInteractionInRtl(fixture, stepHeaders);
10621045
});
10631046

1047+
it('should set the correct aria-posinset and aria-setsize', () => {
1048+
const fixture = createComponent(SimpleMatHorizontalStepperApp);
1049+
fixture.detectChanges();
1050+
1051+
const headers = Array.from<HTMLElement>(
1052+
fixture.nativeElement.querySelectorAll('.mat-step-header'),
1053+
);
1054+
1055+
expect(headers.map(header => header.getAttribute('aria-posinset'))).toEqual(['1', '2', '3']);
1056+
expect(headers.every(header => header.getAttribute('aria-setsize') === '3')).toBe(true);
1057+
});
1058+
10641059
it('should maintain the correct navigation order when a step is added later on', () => {
10651060
const fixture = createComponent(HorizontalStepperWithDelayedStep);
10661061
fixture.detectChanges();

0 commit comments

Comments
 (0)