question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prefilled form for linear stepper doesn't allow one to click on all steps

See original GitHub issue

Bug, feature request, or proposal:

Feature request

What is the expected behavior?

A linear stepper whose associated form is populated using patchValue or setValue and is valid should allow you to click on any of the steps right away.

What is the current behavior?

I have to keep pressing the “next” button as I am restricted to clicking on steps I have visited and the one immediately after.

What are the steps to reproduce?

  1. Create a linear stepper with > 3 steps
  2. Associate the stepper with a form and each step with a form group
  3. Programmatically patch the value of the form groups associated with the steps to a valid state
  4. Not all steps on the stepper are clickable even though the form and the groups are valid

What is the use-case or motivation for changing an existing behavior?

Saving the user’s progress for a long form and returning them to the step they left off on.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

I’m on Angular 5.2.3, Angular Material 5.2, MacOS, TS 2.4.2.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
andymocklicommented, May 25, 2018

Also having this problem in Angular 6.0.1, Material 6.0.2, TS 2.7.2. It was working as @MrSnappingTurtle and I expected in version 2.0.0-beta.12 however.

This issue makes the stepper only usable in “create” mode and not “edit” mode. Which is to say it’s not very usable as a UI component at all when [linear]=“true”. We’re making the move to upgrade to 6.0, but this issue is making me have to rethink our whole UX around our forms.

Is there anything I can do to help get this fixed?

3reactions
vamsikrrishcommented, May 20, 2020

A temporary workaround for this might be like this:

HTML:

<mat-horizontal-stepper  #stepper (animationDone)="setAllMatStepsAsInteracted()" linear>
.
.
.
</mat-horizontal-stepper>

TypeScript:

  @ViewChild('stepper') formStepper: MatStepper;
setAllMatStepsAsInteracted(){
  this.formStepper.steps.forEach((matStep : CdkStep)=>{
    matStep.interacted=true;
  });
}

Note 1: You might decide to check for the validity of each step before u set the stepper as interacted(completely fail safe)

Note 2 : Using completed instead of interacted also works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Material Stepper component prevent going to all the ...
The solution that I found to this problem is to use completed attribute of step. Refer to the line of code given below:....
Read more >
Stepper | Angular Material
Angular Material's stepper provides a wizard-like workflow by dividing content into logical steps. Material stepper builds on the foundation of the CDK ...
Read more >
Angular Material Stepper - GeeksforGeeks
The Stepper Component in the Angular material allows the user to create a wizard-like a workflow by dividing the content into logical steps....
Read more >
Automatic HVAC Air Recirculation Made Easy with Stepper ...
by customer's technical experts. onsemi does not convey any license under any of its ... valve controlled by a linear stepper-motor has previously....
Read more >
Materialize Stepper - GitHub Pages
Linear Stepper is the most common one. In it, you can't navigate freely between steps. It's step by step, obeying the validation function....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found