Skip to content

Commit 16a8495

Browse files
authored
refactor(material/stepper): remove all usages of deprecated selectors (#22838)
The `mat-horizontal-stepper` and `mat-vertical-stepper` were deprecated after we introduced the `orientation` input on `mat-stepper`. These changes update all docs and tests to use the new approach.
1 parent 5a2c495 commit 16a8495

File tree

17 files changed

+105
-109
lines changed

17 files changed

+105
-109
lines changed

src/components-examples/material/stepper/stepper-editable/stepper-editable-example.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{!isEditable ? 'Enable edit mode' : 'Disable edit mode'}}
33
</button>
44

5-
<mat-horizontal-stepper linear #stepper>
5+
<mat-stepper linear #stepper>
66
<!-- #docregion editable -->
77
<mat-step [stepControl]="firstFormGroup" [editable]="isEditable">
88
<!-- #enddocregion editable -->
@@ -41,4 +41,4 @@
4141
<button mat-button (click)="stepper.reset()">Reset</button>
4242
</div>
4343
</mat-step>
44-
</mat-horizontal-stepper>
44+
</mat-stepper>

src/components-examples/material/stepper/stepper-errors/stepper-errors-example.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<mat-horizontal-stepper #stepper>
1+
<mat-stepper #stepper>
22
<mat-step [stepControl]="firstFormGroup" errorMessage="Name is required.">
33
<form [formGroup]="firstFormGroup">
44
<ng-template matStepLabel>Fill out your name</ng-template>
@@ -35,4 +35,4 @@
3535
<button mat-button (click)="stepper.reset()">Reset</button>
3636
</div>
3737
</mat-step>
38-
</mat-horizontal-stepper>
38+
</mat-stepper>

src/components-examples/material/stepper/stepper-harness/stepper-harness-example.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<mat-horizontal-stepper>
1+
<mat-stepper>
22
<mat-step>
33
<ng-template matStepLabel>One</ng-template>
44
<button matStepperNext>Next</button>
@@ -12,4 +12,4 @@
1212
<ng-template matStepLabel>Three</ng-template>
1313
<button matStepperPrevious>Previous</button>
1414
</mat-step>
15-
</mat-horizontal-stepper>
15+
</mat-stepper>

src/components-examples/material/stepper/stepper-intl/stepper-intl-example.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{optionalLabelTextChoice}}
1212
</mat-radio-button>
1313
</mat-radio-group>
14-
<mat-horizontal-stepper class="demo-stepper" #stepper>
14+
<mat-stepper class="demo-stepper" #stepper>
1515
<mat-step [stepControl]="firstFormGroup">
1616
<form [formGroup]="firstFormGroup">
1717
<ng-template matStepLabel>Fill out your name</ng-template>
@@ -56,4 +56,4 @@
5656
<button mat-button (click)="stepper.reset()">Reset</button>
5757
</div>
5858
</mat-step>
59-
</mat-horizontal-stepper>
59+
</mat-stepper>

src/components-examples/material/stepper/stepper-label-position-bottom/stepper-label-position-bottom-example.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- #docregion label-position -->
2-
<mat-horizontal-stepper labelPosition="bottom" #stepper>
2+
<mat-stepper labelPosition="bottom" #stepper>
33
<!-- #enddocregion label-position -->
44
<mat-step [stepControl]="firstFormGroup">
55
<form [formGroup]="firstFormGroup">
@@ -37,4 +37,4 @@
3737
<button mat-button (click)="stepper.reset()">Reset</button>
3838
</div>
3939
</mat-step>
40-
</mat-horizontal-stepper>
40+
</mat-stepper>

src/components-examples/material/stepper/stepper-lazy-content/stepper-lazy-content-example.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<mat-vertical-stepper>
1+
<mat-stepper orientation="vertical">
22
<mat-step>
33
<ng-template matStepLabel>Step 1</ng-template>
44
<ng-template matStepContent>
@@ -19,4 +19,4 @@
1919
<p>This content was rendered eagerly</p>
2020
<button mat-button matStepperPrevious>Back</button>
2121
</mat-step>
22-
</mat-vertical-stepper>
22+
</mat-stepper>

src/components-examples/material/stepper/stepper-optional/stepper-optional-example.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{!isOptional ? 'Enable optional steps' : 'Disable optional steps'}}
33
</button>
44

5-
<mat-horizontal-stepper linear #stepper>
5+
<mat-stepper linear #stepper>
66
<mat-step [stepControl]="firstFormGroup">
77
<form [formGroup]="firstFormGroup">
88
<ng-template matStepLabel>Fill out your name</ng-template>
@@ -39,4 +39,4 @@
3939
<button mat-button (click)="stepper.reset()">Reset</button>
4040
</div>
4141
</mat-step>
42-
</mat-horizontal-stepper>
42+
</mat-stepper>

src/components-examples/material/stepper/stepper-overview/stepper-overview-example.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<button mat-raised-button (click)="isLinear = !isLinear" id="toggle-linear">
22
{{!isLinear ? 'Enable linear mode' : 'Disable linear mode'}}
33
</button>
4-
<mat-horizontal-stepper [linear]="isLinear" #stepper>
4+
<mat-stepper [linear]="isLinear" #stepper>
55
<mat-step [stepControl]="firstFormGroup">
66
<form [formGroup]="firstFormGroup">
77
<ng-template matStepLabel>Fill out your name</ng-template>
@@ -37,4 +37,4 @@
3737
<button mat-button (click)="stepper.reset()">Reset</button>
3838
</div>
3939
</mat-step>
40-
</mat-horizontal-stepper>
40+
</mat-stepper>

src/components-examples/material/stepper/stepper-states/stepper-states-example.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<mat-horizontal-stepper #stepper>
1+
<mat-stepper #stepper>
22
<mat-step [stepControl]="firstFormGroup">
33
<form [formGroup]="firstFormGroup">
44
<ng-template matStepLabel>Fill out your name</ng-template>
@@ -33,10 +33,10 @@
3333
<button mat-button (click)="stepper.reset()">Reset</button>
3434
</div>
3535
</mat-step>
36-
</mat-horizontal-stepper>
36+
</mat-stepper>
3737

3838
<!-- #docregion states -->
39-
<mat-horizontal-stepper>
39+
<mat-stepper>
4040
<!-- #docregion label -->
4141
<mat-step label="Step 1" state="phone">
4242
<p>Put down your phones.</p>
@@ -64,6 +64,6 @@
6464
<ng-template matStepperIcon="chat">
6565
<mat-icon>forum</mat-icon>
6666
</ng-template>
67-
</mat-horizontal-stepper>
67+
</mat-stepper>
6868
<!-- #enddocregion override-icons -->
6969
<!-- #enddocregion states -->

src/components-examples/material/stepper/stepper-vertical/stepper-vertical-example.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<button mat-raised-button (click)="isLinear = !isLinear" id="toggle-linear">
22
{{!isLinear ? 'Enable linear mode' : 'Disable linear mode'}}
33
</button>
4-
<mat-vertical-stepper [linear]="isLinear" #stepper>
4+
<mat-stepper orientation="vertical" [linear]="isLinear" #stepper>
55
<mat-step [stepControl]="firstFormGroup">
66
<form [formGroup]="firstFormGroup">
77
<ng-template matStepLabel>Fill out your name</ng-template>
@@ -36,4 +36,4 @@
3636
<button mat-button (click)="stepper.reset()">Reset</button>
3737
</div>
3838
</mat-step>
39-
</mat-vertical-stepper>
39+
</mat-stepper>

src/dev-app/stepper/stepper-demo.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ <h3>Linear Stepper Demo using a single form</h3>
7676
</form>
7777

7878
<h3>Linear Horizontal Stepper Demo using a different form for each step</h3>
79-
<mat-horizontal-stepper #linearHorizontalStepper="matHorizontalStepper" [linear]="!isNonLinear"
79+
<mat-stepper #linearHorizontalStepper="matHorizontalStepper" [linear]="!isNonLinear"
8080
[disableRipple]="disableRipple"
8181
[labelPosition]="showLabelBottom ? 'bottom' : 'end'"
8282
[color]="theme">
@@ -124,11 +124,11 @@ <h3>Linear Horizontal Stepper Demo using a different form for each step</h3>
124124
</div>
125125
</form>
126126
</mat-step>
127-
</mat-horizontal-stepper>
127+
</mat-stepper>
128128

129129
<h3>Vertical Stepper Demo</h3>
130130
<mat-checkbox [(ngModel)]="isNonEditable">Make steps non-editable</mat-checkbox>
131-
<mat-vertical-stepper [color]="theme">
131+
<mat-stepper orientation="vertical" [color]="theme">
132132
<mat-step [editable]="!isNonEditable">
133133
<ng-template matStepLabel>Fill out your name</ng-template>
134134
<mat-form-field>
@@ -180,10 +180,10 @@ <h3>Vertical Stepper Demo</h3>
180180
<button mat-button>Done</button>
181181
</div>
182182
</mat-step>
183-
</mat-vertical-stepper>
183+
</mat-stepper>
184184

185185
<h3>Horizontal Stepper Demo with Text Label</h3>
186-
<mat-horizontal-stepper [color]="theme">
186+
<mat-stepper [color]="theme">
187187
<mat-step label="Fill out your name">
188188
<mat-form-field>
189189
<mat-label>First name</mat-label>
@@ -227,10 +227,10 @@ <h3>Horizontal Stepper Demo with Text Label</h3>
227227
<button mat-button>Done</button>
228228
</div>
229229
</mat-step>
230-
</mat-horizontal-stepper>
230+
</mat-stepper>
231231

232232
<h3>Horizontal Stepper Demo with Templated Label</h3>
233-
<mat-horizontal-stepper [color]="theme">
233+
<mat-stepper [color]="theme">
234234
<mat-step *ngFor="let step of steps">
235235
<ng-template matStepLabel>{{step.label}}</ng-template>
236236
<mat-form-field>
@@ -242,15 +242,15 @@ <h3>Horizontal Stepper Demo with Templated Label</h3>
242242
<button mat-button matStepperNext>Next</button>
243243
</div>
244244
</mat-step>
245-
</mat-horizontal-stepper>
245+
</mat-stepper>
246246

247247
<h3>Stepper with autosize textarea</h3>
248-
<mat-horizontal-stepper [color]="theme">
248+
<mat-stepper [color]="theme">
249249
<mat-step label="Step 1">
250250
<mat-form-field>
251251
<mat-label>Autosize textarea</mat-label>
252252
<textarea matInput cdkTextareaAutosize>This is an autosize textarea, it should adjust to the size of its content.</textarea>
253253
</mat-form-field>
254254
</mat-step>
255-
</mat-horizontal-stepper>
255+
</mat-stepper>
256256

src/material/input/input.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,15 +2245,15 @@ class AutosizeTextareaInATab {}
22452245

22462246
@Component({
22472247
template: `
2248-
<mat-horizontal-stepper>
2248+
<mat-stepper>
22492249
<mat-step label="Step 1">
22502250
<mat-form-field>
22512251
<textarea matInput matTextareaAautosize>
22522252
Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
22532253
</textarea>
22542254
</mat-form-field>
22552255
</mat-step>
2256-
</mat-horizontal-stepper>
2256+
</mat-stepper>
22572257
`
22582258
})
22592259
class AutosizeTextareaInAStep {}

src/material/stepper/stepper.e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('stepper', () => {
55
beforeEach(async () => await browser.get('/stepper'));
66

77
it('should render a stepper', async () => {
8-
await expectToExist('mat-horizontal-stepper');
8+
await expectToExist('mat-stepper');
99
});
1010

1111
describe('basic behavior', () => {

src/material/stepper/stepper.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@ that drives a stepped workflow. Material stepper extends the CDK stepper and has
55
styling.
66

77
### Stepper variants
8-
There are two stepper components: `mat-horizontal-stepper` and `mat-vertical-stepper`. They
9-
can be used the same way. The only difference is the orientation of stepper.
8+
There are two stepper variants: `horizontal` and `vertical`. You can switch between the two using
9+
the `orientation` attribute.
1010

1111
<!-- example(stepper-overview) -->
1212

1313
<!-- example(stepper-vertical) -->
1414

15-
`mat-horizontal-stepper` selector can be used to create a horizontal stepper, and
16-
`mat-vertical-stepper` can be used to create a vertical stepper. `mat-step` components need to be
17-
placed inside either one of the two stepper components.
18-
1915
### Labels
2016
If a step's label is only text, then the `label` attribute can be used.
2117
<!-- example({"example": "stepper-overview",
@@ -29,7 +25,7 @@ For more complex labels, add a template with the `matStepLabel` directive inside
2925
"region": "step-label"}) -->
3026

3127
#### Label position
32-
For `mat-horizontal-stepper` it's possible to define the position of the label. `end` is the
28+
For a horizontal `mat-stepper` it's possible to define the position of the label. `end` is the
3329
default value, while `bottom` will place it under the step icon instead of at its side.
3430
This behaviour is controlled by `labelPosition` property.
3531

@@ -45,10 +41,10 @@ There are two button directives to support navigation between different steps:
4541
"region": "buttons"}) -->
4642

4743
### Linear stepper
48-
The `linear` attribute can be set on `mat-horizontal-stepper` and `mat-vertical-stepper` to create
49-
a linear stepper that requires the user to complete previous steps before proceeding to following
50-
steps. For each `mat-step`, the `stepControl` attribute can be set to the top level
51-
`AbstractControl` that is used to check the validity of the step.
44+
The `linear` attribute can be set on `mat-stepper` to create a linear stepper that requires the
45+
user to complete previous steps before proceeding to following steps. For each `mat-step`, the
46+
`stepControl` attribute can be set to the top level `AbstractControl` that is used to check the
47+
validity of the step.
5248

5349
There are two possible approaches. One is using a single form for stepper, and the other is
5450
using a different form for each step.
@@ -64,7 +60,7 @@ are completed.
6460

6561
```html
6662
<form [formGroup]="formGroup">
67-
<mat-horizontal-stepper formArrayName="formArray" linear>
63+
<mat-stepper formArrayName="formArray" linear>
6864
<mat-step formGroupName="0" [stepControl]="formArray.get([0])">
6965
...
7066
<div>
@@ -79,13 +75,13 @@ are completed.
7975
</div>
8076
</mat-step>
8177
...
82-
</mat-horizontal-stepper>
78+
</mat-stepper>
8379
</form>
8480
```
8581

8682
#### Using a different form for each step
8783
```html
88-
<mat-vertical-stepper linear>
84+
<mat-stepper orientation="vertical" linear>
8985
<mat-step [stepControl]="formGroup1">
9086
<form [formGroup]="formGroup1">
9187
...
@@ -96,7 +92,7 @@ are completed.
9692
...
9793
</form>
9894
</mat-step>
99-
</mat-vertical-stepper>
95+
</mat-stepper>
10096
```
10197
### Types of steps
10298

0 commit comments

Comments
 (0)