Description
Reproduction
https://stackblitz.com/edit/angular-zxzjbv
Steps to reproduce:
The goal is to load a stepper, where some steps are (conditionally) pre-completed.
For example: Step2: Complete, Step3: Not Complete
- Create a stepper, with multiple steps. Each step has a "completed" binding to a variable.
- Set some of these bindings to true, and others to false.
- “Walk” to step 2, step 3, then back to step 2 and step 1.
Expected Behavior
Step 3 should now be complete.
Actual Behavior
Step 3 is not complete, and is hard locked into a completed=false state.
Requests
Each step should have a (completed)
output even. For 2 reasons:
- We can have a 2 way binding with initial state. Eg:
<mat-step [(completed)]="completed"
And it is then easy to set the initial state in ngOnInit
to whatever.
- There is currently (AFAIK) no way to react on a step being completed. Note that listening to step change events does not work, because with a linear stepper with invalid steps, clicking on next will complete the step, without actually moving to another step.
Workaround
Our current workaround is to add a @ViewChildren(MatStep) matSteps
and then manually do matSteps[1].completed = true;
However, this requires a lot of extra code, and it’s never clear if the child really expects its properties to be changed directly that way.
More importantly though, you can visibly see the stepper load in a non-completed state, and only visibly transition to completed once all the step contents have been loaded.
Environment
- Angular: 10.0.0
- CDK/Material: 10.0.0
- Browser: Google Chrome Version 84.0.4147.94 (Official Build) (64-bit)
- Operating System: Google Chrome OS Version 84.0.4147.94 (Official Build) (64-bit)