Skip to content

bug(MatStepper): MatStep’s completed should be a 2 way binding #20215

Open
@paulferaud

Description

@paulferaud

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

  1. Create a stepper, with multiple steps. Each step has a "completed" binding to a variable.
  2. Set some of these bindings to true, and others to false.
  3. “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:

  1. 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.

  1. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    GThis is is related to a Google internal issueP3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/stepperfeatureThis issue represents a new feature or feature request rather than a bug or bug fixneeds: discussionFurther discussion with the team is needed before proceeding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions