Skip to content

Commit 80cc296

Browse files
committed
refactor(material/stepper): remove shared mat-step-header
Updates previous fix to create individual mat-step-header tags to be used within the horizontal and vertical steppers to make it easier to edit/understand.
1 parent a7565c7 commit 80cc296

File tree

1 file changed

+47
-36
lines changed

1 file changed

+47
-36
lines changed

src/material/stepper/stepper.html

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,31 @@
1313
<div class="mat-horizontal-stepper-wrapper">
1414
<div class="mat-horizontal-stepper-header-container" role="tablist">
1515
@for (step of steps; track step) {
16-
<ng-container
17-
[ngTemplateOutlet]="stepTemplate"
18-
[ngTemplateOutletContext]="{step, i: $index}"/>
16+
<mat-step-header
17+
class="mat-horizontal-stepper-header"
18+
role="tab"
19+
(click)="step.select()"
20+
(keydown)="_onKeydown($event)"
21+
[tabIndex]="_getFocusIndex() === $index ? 0 : -1"
22+
[id]="_getStepLabelId($index)"
23+
[attr.aria-posinset]="$index + 1"
24+
[attr.aria-setsize]="steps.length"
25+
[attr.aria-controls]="_getStepContentId($index)"
26+
[attr.aria-owns]="_getStepContentId($index)"
27+
[attr.aria-selected]="selectedIndex == $index"
28+
[attr.aria-label]="step.ariaLabel || null"
29+
[attr.aria-labelledby]="(!step.ariaLabel && step.ariaLabelledby) ? step.ariaLabelledby : null"
30+
[attr.aria-disabled]="_stepIsNavigable($index, step) ? null : true"
31+
[index]="$index"
32+
[state]="_getIndicatorType($index, step.state)"
33+
[label]="step.stepLabel || step.label"
34+
[selected]="selectedIndex === $index"
35+
[active]="_stepIsNavigable($index, step)"
36+
[optional]="step.optional"
37+
[errorMessage]="step.errorMessage"
38+
[iconOverrides]="_iconOverrides"
39+
[disableRipple]="disableRipple || !_stepIsNavigable($index, step)"
40+
[color]="step.color || color"/>
1941
@if (!$last) {
2042
<div class="mat-stepper-horizontal-line"></div>
2143
}
@@ -43,9 +65,28 @@
4365
<div class="mat-vertical-stepper-wrapper" role="group">
4466
@for (step of steps; track step) {
4567
<div class="mat-step" role="group">
46-
<ng-container
47-
[ngTemplateOutlet]="stepTemplate"
48-
[ngTemplateOutletContext]="{step, i: $index}"/>
68+
<mat-step-header
69+
class="mat-vertical-stepper-header"
70+
role="button"
71+
(click)="step.select()"
72+
(keydown)="_onKeydown($event)"
73+
[tabIndex]="_getFocusIndex() === $index ? 0 : -1"
74+
[id]="_getStepLabelId($index)"
75+
[attr.aria-current]="selectedIndex == $index"
76+
[attr.aria-label]="step.ariaLabel || null"
77+
[attr.aria-labelledby]="(!step.ariaLabel && step.ariaLabelledby) ? step.ariaLabelledby : null"
78+
[attr.aria-disabled]="_stepIsNavigable($index, step) ? null : true"
79+
[attr.aria-owns]="_getStepContentId($index)"
80+
[index]="$index"
81+
[state]="_getIndicatorType($index, step.state)"
82+
[label]="step.stepLabel || step.label"
83+
[selected]="selectedIndex === $index"
84+
[active]="_stepIsNavigable($index, step)"
85+
[optional]="step.optional"
86+
[errorMessage]="step.errorMessage"
87+
[iconOverrides]="_iconOverrides"
88+
[disableRipple]="disableRipple || !_stepIsNavigable($index, step)"
89+
[color]="step.color || color"/>
4990
<div
5091
#animatedContainer
5192
class="mat-vertical-content-container"
@@ -66,33 +107,3 @@
66107
</div>
67108
}
68109
}
69-
70-
<!-- Common step templating -->
71-
<ng-template let-step="step" let-i="i" #stepTemplate>
72-
<mat-step-header
73-
[class.mat-horizontal-stepper-header]="orientation === 'horizontal'"
74-
[class.mat-vertical-stepper-header]="orientation === 'vertical'"
75-
[attr.role]="orientation === 'horizontal' ? 'tab' : 'button'"
76-
(click)="step.select()"
77-
(keydown)="_onKeydown($event)"
78-
[tabIndex]="_getFocusIndex() === i ? 0 : -1"
79-
[id]="_getStepLabelId(i)"
80-
[attr.aria-posinset]="orientation === 'horizontal' ? i + 1 : undefined"
81-
[attr.aria-setsize]="orientation === 'horizontal' ? steps.length : undefined"
82-
[attr.aria-controls]="orientation === 'horizontal' ? _getStepContentId(i) : undefined"
83-
[attr.aria-selected]="orientation === 'horizontal' ? selectedIndex == i : undefined"
84-
[attr.aria-current]="orientation === 'vertical' ? selectedIndex == i : undefined"
85-
[attr.aria-label]="step.ariaLabel || `Step ${i+1}`"
86-
[attr.aria-labelledby]="(!step.ariaLabel && step.ariaLabelledby) ? step.ariaLabelledby : null"
87-
[attr.aria-disabled]="_stepIsNavigable(i, step) ? null : true"
88-
[index]="i"
89-
[state]="_getIndicatorType(i, step.state)"
90-
[label]="step.stepLabel || step.label"
91-
[selected]="selectedIndex === i"
92-
[active]="_stepIsNavigable(i, step)"
93-
[optional]="step.optional"
94-
[errorMessage]="step.errorMessage"
95-
[iconOverrides]="_iconOverrides"
96-
[disableRipple]="disableRipple || !_stepIsNavigable(i, step)"
97-
[color]="step.color || color"/>
98-
</ng-template>

0 commit comments

Comments
 (0)