Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mat-Stepper] A few suggestions #7700

Closed
christikaes opened this issue Oct 11, 2017 · 40 comments
Closed

[Mat-Stepper] A few suggestions #7700

christikaes opened this issue Oct 11, 2017 · 40 comments
Assignees
Labels
area: cdk/stepper feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@christikaes
Copy link
Contributor

christikaes commented Oct 11, 2017

Thanks for everyone who works on this project! I just upgraded to beta12 and am using the Stepper component now. I had a few proposals after using it for a bit. Please let me know what you think-I'd love to help contribute if we want any of these (:

  1. Mat-Stepper with horizontal/vertical as an input.
    • Use Case: I have a stepper that I want to toggle between horizontal/vertical for different screen aspect ratios but with the same content and steps. Currently I would need to create two separate components and toggle between the two which feels messy.
    • Proposal: Replace mat-vertical-stepper and mat-horizontal-stepper with mat-stepper that takes in an input to toggle between the two views
  2. SelectedIndex as input.
  3. Reset Stepper.
    • Use Case: I want to reset the stepper. I am using formGroup.reset() to reset each form, but this does not reset the visited states of each one of the steps.
    • Proposal: Some way of resetting the stepper component to the initial state: First step is selected, Forms are reset, None of the steps have been touched etc.
  4. Animate Height.
    • Use Case: Currently the steps slide right/left but the height of the stepper does not transition smoothly.
    • Proposal: Transition the height of the steps when changing from one step to the other
      Let me know what you think~
@sam-lex
Copy link

sam-lex commented Oct 11, 2017

Would like to add one more suggestion here as well:
5. Disabled step. Or a way to add/remove steps.

  • Use Case: Additional steps depending on what is being selected in previous steps. (like a wizard form).

I was able to add steps with something like this:

<mat-step *ngFor="let invForm of inventoryForms"
    [stepControl]="invForm.form" [label]="invForm.item.product.name">
</mat-step>

but if I go back to previous step, and change it so that these additional steps aren't required, and setting this.inventoryForms = [], the steps are not removed from the stepper.
Even wrapping it inside a <ng-container *ngIf="inventoryForms.length > 0"> did not work. 😞

@sam-lex
Copy link

sam-lex commented Oct 12, 2017

I got a work-around, but is probably a bad idea 😅

  1. Make a reference to the stepper:
<mat-vertical-stepper #stepper></mat-vertical-stepper>
  1. Then, on the .ts side:
import { ViewChild } from '@angular/core';
import { MatVerticalStepper } from '@angular/material';

@ViewChild('stepper') stepper: MatVerticalStepper;

clearAdditionalForms(): void {
  this.inventoryForms = [];
  this.stepper._stateChanged(); // <- this : Marks the component to be change detected.
}

@justinwaite
Copy link

I would like to also leave a suggestion.
6. Async step support. If each step is using it's own FormGroup, while using linear="true", the forms should be submitted before moving on to the next step.

@andrewseguin andrewseguin added the feature This issue represents a new feature or feature request rather than a bug or bug fix label Oct 13, 2017
@davidrensh
Copy link

disabled attribute is must have.
For example: we have 5 steps, step N is disabled by business logic. Then it should be gray out and not editable

@spongessuck
Copy link

Perhaps related to 4. Animate Height: having it animate the same way tab transitions where you see the current content slide out

@vegham
Copy link

vegham commented Nov 5, 2017

Have any one a solution for suggestion 1? I tried quickly the same as in #8014 but ran into same issues.

@Misiu
Copy link

Misiu commented Nov 21, 2017

As @jdeanwaite suggested async step support is critical.
I need to create 5 step process, when user clicks Next I'd like to submit data from that step to server, so that user can come back later and resume process.

linear="true" solves problem with disabling ability to move to next step before filling current, but there should be option to disable moving back. In my case when user submits current step by clicking Next he can't move back. Currently he can click Back button or use labels to navigate, so disable attribute is a must have for me.

@mmalerba mmalerba added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Nov 21, 2017
crisbeto added a commit to crisbeto/material2 that referenced this issue Nov 23, 2017
Allows for the user to reset a stepper to its initial state by calling the `reset` method.

Relates to angular#7700.
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 3, 2017
Allows for the user to reset a stepper to its initial state by calling the `reset` method.

Relates to angular#7700.
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 14, 2017
Allows for the user to reset a stepper to its initial state by calling the `reset` method.

Relates to angular#7700.
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 30, 2017
* Turns the `MatStepper` into a proper component that allows consumers to switch between `horizontal` and `vertical` dynamically, allowing for use cases like having a different layout depending on the screen size.
* Combines the `mat-vertical-stepper` and `mat-horizontal-stepper` templates into a single file to avoid all the code duplication.

Relates to angular#7700.
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 31, 2017
* Turns the `MatStepper` into a proper component that allows consumers to switch between `horizontal` and `vertical` dynamically, allowing for use cases like having a different layout depending on the screen size.
* Combines the `mat-vertical-stepper` and `mat-horizontal-stepper` templates into a single file to avoid all the code duplication.

Relates to angular#7700.
crisbeto added a commit to crisbeto/material2 that referenced this issue Jan 14, 2018
Allows for the user to reset a stepper to its initial state by calling the `reset` method.

Relates to angular#7700.
jelbourn pushed a commit that referenced this issue Jan 23, 2018
Allows for the user to reset a stepper to its initial state by calling the `reset` method.

Relates to #7700.
@markobalogh2
Copy link

I'd like to add: it would be nice if we could implement the dynamicHeight input that mat-tab-group has. I recently tried to replace a tab group with a stepper but I get painful layout problems due to each mat-step's height adapting to its content. Using a mat-tab-group I managed a workaround by setting dynamicHeight false. It seems the dynamicHeight behavior we have in mat-tab-group is something people are asking for anyway.

@vanmxpx
Copy link

vanmxpx commented Apr 18, 2018

That is how to add steps dynamically -
<mat-step *ngIf="*expression*"></mat-step>

@tonysamperi
Copy link

tonysamperi commented Apr 19, 2018

Anything new about disabling single steps?

EDIT

The way to disable steps is to add on the `' a editable attribute.

<mat-step [editable]="myStepEditable">...</mat-step>

It worked for me because I need to handle disabled after the step was
completed already...

I don't know if this can prevent entering next steps...

@AGPX
Copy link

AGPX commented May 8, 2018

Another great limitation of the steppers is that you cannot grow it to fill the entire parent space. I have a horizontal stepper and I want that the steps content cover all the available space (vertically). AFAIK there is no way to obtain this basic functionality. Any suggestion?

@tonysamperi
Copy link

@AGPX are you using @angular/flex-layout?

@AGPX
Copy link

AGPX commented May 8, 2018

@tonysamperi for sure, the problem is that the step contents are put inside a div with the class 'mat-horizontal-stepper-content'. Unfortunately, if you add the style 'height: 100%' this will grow all the steps including the hidden (not actived step), because they are hidden through the style 'visibility:hidden' instead of 'display:none' and so the previous hidden steps shift down the actived one. In addition, I found no example of what I wish to achieve.

@tonysamperi
Copy link

@AGPX can you do a stackblitz?
You can fork mine...
https://stackblitz.com/edit/angular-mat-stepper-program

@AGPX
Copy link

AGPX commented May 8, 2018

@tonysamperi sorry, but the proxy of my company don't allow me to use stackblitz (I will make this example from my home, later). I try, however, to explain my problem now.

Looking at the generated DOM of the stepper you have:


<div class="mat-horizontal-content-container">
   <div class="mat-horizontal-stepper-content ng-tns-c12-2 ng-trigger ng-trigger-stepTransition ng-star-inserted" role="tabpanel" id="cdk-step-content-0-0" aria-labelledby="cdk-step-label-0-0" aria-expanded="false" style="transform: translate3d(-100%, 0px, 0px); visibility: hidden;">

	  my contents of step 1 go here...
   </div>
   <div class="mat-horizontal-stepper-content ng-tns-c12-2 ng-trigger ng-trigger-stepTransition ng-star-inserted" role="tabpanel" id="cdk-step-content-0-0" aria-labelledby="cdk-step-label-0-0" aria-expanded="false" style="transform: translate3d(-100%, 0px, 0px); visibility: visible;">

	  my contents of step 2 go here...
   </div>
</div>

The only way to expand my content vertically in order to cover the entire vertical space is to add the style 'height: 100%' to 'mat-horizontal-stepper-content' and 'mat-horizontal-content-container' classes. Unfortunately, the 'mat-horizontal-stepper-content' is shared amongs all the steps and this will grow also the step 1 div (that is hidden). The result is that the step 2 content is shifted down.

@tonysamperi
Copy link

@AGPX
Copy link

AGPX commented May 9, 2018

@tonysamperi eh... the div should cover the entire vertical space...

@tonysamperi
Copy link

@AGPX sorry, it did when I posted...maybe I didn't save...

@tonysamperi
Copy link

tonysamperi commented May 9, 2018

@AGPX ok it should work now...
https://stackblitz.com/edit/angular-mat-stepper-full-height

joyo

@AGPX
Copy link

AGPX commented May 9, 2018

@tonysamperi thank you very much, it works! A bit tricky though, I think that this should be supported natively by the stepper component. Anyway, thanks again!

@probert94
Copy link

@tonysamperi @AGPX I had the same problem and found a pretty simple solution.

The Idea is, that the height: 100% is only applied to the active step.
This can be achieved using following css-rule:

.mat-horizontal-stepper-content[aria-expanded=true] {
	height: 100%;
	display: flex;
	flex-direction: column;
}

I used flex-direction: column, so that the content of <mat-step> can be laid out as a column, without adding an extra container.
I also added a css-class full-height, which I configure in the style.css. That way I can use ViewEncapsulation.

So basically you only need to do the following:

  • <mat-horizontal-stepper> has to be 100% high.
  • .mat-horizontal-content-container has to be 100% high.
  • .mat-horizontal-stepper-content of active step has to be 100% high (.mat-horizontal-stepper-content[aria-expanded=true]).
  • .mat-horizontal-stepper-content of active step has to be 0px high (.mat-horizontal-stepper-content[aria-expanded=false]).

@tonysamperi
Copy link

@Springrbua good to know. Thanks!

@AGPX
Copy link

AGPX commented May 23, 2018

@Springrbua Thanks for the hint. However, IMHO, the stepper should support this capability natively. Generally speaking (coming from other frameworks), Angular Material should be by far more customizable.

@probert94
Copy link

@AGPX I agree, that the stepper should allow you to easily customize the height of th stepper-content.
Usually you want to have the buttons (back and next) always at the same spot and therefore you need a fixed height.

Angular Material should be by far more customizable.
I don't really agree with you on that. Angular Material follows the material design specs and does a great job at that. Of course, a few components could give a little more freedom, but not too much.
If you need more freedom, then you should probably use the CDK, which Angular Material uses under the hood.

@AGPX
Copy link

AGPX commented May 23, 2018

Angular Material follows the material design specs...

@Springrbua probably my problem is actually material design, or better the decision to adopt it. My boss tell me "...remove the underline on the input text...", "...put label on the left...", "...change this and that..." and I found very very difficult to apply any cosmetic changes to Material. Probably Angular Material is not the framework tailored for our needs, but it's not my choice (probably it was chosen without a sufficient understanding of its philosophy)... so I have to found workarounds. Forgive me, I'm only a coder. Thanks anyway for the precious support!

@probert94
Copy link

probert94 commented May 23, 2018

@AGPX Take a look at the cdk, maybe it is what you are looking for. Basically all material components are build on top of it and add material design style to it. If you don't need material design style it might be what you are looking for.

@tonysamperi
Copy link

@AGPX you should have a more "component-wise" approach.
Of course setting height for the stepper is a very specific change.
But if you want any inputs to have the label on the left, you just create a component which wraps a matInput but never sets the placeholder...Maybe this requires time, but it allows you to create a set based on your project (and always reusable even outside).

Angular Material should be by far more customizable.

@no-more
Copy link

no-more commented Aug 27, 2018

Any plan to implement disabled state or it's a no-go feature ?
This is very useful in order to have more dynamic steps without inserting/removing steps dynamically which would be not intuitive for the users.

Thanks a lot.

@umarsuhail
Copy link

How can we set success after completion of all state?

@akvaliya
Copy link

akvaliya commented Mar 20, 2019

@AGPX ok it should work now...
https://stackblitz.com/edit/angular-mat-stepper-full-height

joyo

I want the same. But want stepper fix at the bottom of the page & section should scroll.

Any idea how to achieve that.

@tonysamperi
Copy link

@akvaliya if I remember correctly the stepper and the content are flex.
You can swap the order with a simple rule: flex-direction: column-reverse

@kungufli
Copy link

I'm trying to get the same style requested by @AGPX (horizontal stepper with the steps content cover all the available vertical space), but I'm struggling to get it. Even the workarounds suggested by @tonysamperi and @Springrbua aren't working for me, maybe they worked well when posted, but they don't for sure on version 10.1.3, that I'm using.

Any suggestion?

@tonysamperi
Copy link

tonysamperi commented Aug 18, 2020

@kungufli I suggest not using github as stackoverflow.
I think you should create a post there and show what you've tried so far.
I think you should at least create a stackblitz with your environment so that anyone can take a look and maybe help you out!

crisbeto added a commit to crisbeto/material2 that referenced this issue Mar 7, 2021
Combines `mat-vertical-stepper` and `mat-horizontal-stepper` into a single `mat-stepper`
class in order to allow for the orientation to be changed dynamically. Also deprecates
`MatVerticalStepper` and `MatHorizontalStepper`.

This is a reimplementation of angular#9173, however this time I took a different approach which should
make it easier to maintain and eventually remove the two separate steppers. It should result in a
smaller bundle as well. The main differences are:

1. Rather than have 3 components (`MatStepper`, `MatVerticalStepper` and `MatHorizontalStepper`),
these changes combine everything into `MatStepper` while `MatVerticalStepper` and
`MatHorizontalStepper` are only used as injection tokens for backwards compatibility. The `selector`
and `exportAs` of `MatStepper` is changed to match the two individual steppers and the orientation
is inferred from the tag name. This will make it much easier to remove the deprecated directives.
Furthermore, it should result in a smaller bundle since the template and styles only need to be
inlined in one place.
2. `MatVerticalStepper` and `MatHorizontalStepper` are turned into very basic directives that have
the same public API as `MatStepper` and they proxy everything to it. This is primarily so that if
somebody managed to get a hold of a `MatVerticalStepper` or `MatHorizontalStepper` instance, or
they used the old classes to type their own code, it wouldn't result in a breaking change.

Relates to angular#7700.
crisbeto added a commit to crisbeto/material2 that referenced this issue Mar 7, 2021
Combines `mat-vertical-stepper` and `mat-horizontal-stepper` into a single `mat-stepper`
class in order to allow for the orientation to be changed dynamically. Also deprecates
`MatVerticalStepper` and `MatHorizontalStepper`.

This is a reimplementation of angular#9173, however this time I took a different approach which should
make it easier to maintain and eventually remove the two separate steppers. It should result in a
smaller bundle as well. The main differences are:

1. Rather than have 3 components (`MatStepper`, `MatVerticalStepper` and `MatHorizontalStepper`),
these changes combine everything into `MatStepper` while `MatVerticalStepper` and
`MatHorizontalStepper` are only used as injection tokens for backwards compatibility. The `selector`
and `exportAs` of `MatStepper` is changed to match the two individual steppers and the orientation
is inferred from the tag name. This will make it much easier to remove the deprecated directives.
Furthermore, it should result in a smaller bundle since the template and styles only need to be
inlined in one place.
2. `MatVerticalStepper` and `MatHorizontalStepper` are turned into very basic directives that have
the same public API as `MatStepper` and they proxy everything to it. This is primarily so that if
somebody managed to get a hold of a `MatVerticalStepper` or `MatHorizontalStepper` instance, or
they used the old classes to type their own code, it wouldn't result in a breaking change.

Relates to angular#7700.
crisbeto added a commit to crisbeto/material2 that referenced this issue Mar 7, 2021
Combines `mat-vertical-stepper` and `mat-horizontal-stepper` into a single `mat-stepper`
class in order to allow for the orientation to be changed dynamically. Also deprecates
`MatVerticalStepper` and `MatHorizontalStepper`.

This is a reimplementation of angular#9173, however this time I took a different approach which should
make it easier to maintain and eventually remove the two separate steppers. It should result in a
smaller bundle as well. The main differences are:

1. Rather than have 3 components (`MatStepper`, `MatVerticalStepper` and `MatHorizontalStepper`),
these changes combine everything into `MatStepper` while `MatVerticalStepper` and
`MatHorizontalStepper` are only used as injection tokens for backwards compatibility. The `selector`
and `exportAs` of `MatStepper` is changed to match the two individual steppers and the orientation
is inferred from the tag name. This will make it much easier to remove the deprecated directives.
Furthermore, it should result in a smaller bundle since the template and styles only need to be
inlined in one place.
2. `MatVerticalStepper` and `MatHorizontalStepper` are turned into very basic directives that have
the same public API as `MatStepper` and they proxy everything to it. This is primarily so that if
somebody managed to get a hold of a `MatVerticalStepper` or `MatHorizontalStepper` instance, or
they used the old classes to type their own code, it wouldn't result in a breaking change.

Relates to angular#7700.
crisbeto added a commit to crisbeto/material2 that referenced this issue Mar 12, 2021
Combines `mat-vertical-stepper` and `mat-horizontal-stepper` into a single `mat-stepper`
class in order to allow for the orientation to be changed dynamically. Also deprecates
`MatVerticalStepper` and `MatHorizontalStepper`.

This is a reimplementation of angular#9173, however this time I took a different approach which should
make it easier to maintain and eventually remove the two separate steppers. It should result in a
smaller bundle as well. The main differences are:

1. Rather than have 3 components (`MatStepper`, `MatVerticalStepper` and `MatHorizontalStepper`),
these changes combine everything into `MatStepper` while `MatVerticalStepper` and
`MatHorizontalStepper` are only used as injection tokens for backwards compatibility. The `selector`
and `exportAs` of `MatStepper` is changed to match the two individual steppers and the orientation
is inferred from the tag name. This will make it much easier to remove the deprecated directives.
Furthermore, it should result in a smaller bundle since the template and styles only need to be
inlined in one place.
2. `MatVerticalStepper` and `MatHorizontalStepper` are turned into very basic directives that have
the same public API as `MatStepper` and they proxy everything to it. This is primarily so that if
somebody managed to get a hold of a `MatVerticalStepper` or `MatHorizontalStepper` instance, or
they used the old classes to type their own code, it wouldn't result in a breaking change.

Relates to angular#7700.
crisbeto added a commit to crisbeto/material2 that referenced this issue Mar 12, 2021
Combines `mat-vertical-stepper` and `mat-horizontal-stepper` into a single `mat-stepper`
class in order to allow for the orientation to be changed dynamically. Also deprecates
`MatVerticalStepper` and `MatHorizontalStepper`.

This is a reimplementation of angular#9173, however this time I took a different approach which should
make it easier to maintain and eventually remove the two separate steppers. It should result in a
smaller bundle as well. The main differences are:

1. Rather than have 3 components (`MatStepper`, `MatVerticalStepper` and `MatHorizontalStepper`),
these changes combine everything into `MatStepper` while `MatVerticalStepper` and
`MatHorizontalStepper` are only used as injection tokens for backwards compatibility. The `selector`
and `exportAs` of `MatStepper` is changed to match the two individual steppers and the orientation
is inferred from the tag name. This will make it much easier to remove the deprecated directives.
Furthermore, it should result in a smaller bundle since the template and styles only need to be
inlined in one place.
2. `MatVerticalStepper` and `MatHorizontalStepper` are turned into very basic directives that have
the same public API as `MatStepper` and they proxy everything to it. This is primarily so that if
somebody managed to get a hold of a `MatVerticalStepper` or `MatHorizontalStepper` instance, or
they used the old classes to type their own code, it wouldn't result in a breaking change.

Relates to angular#7700.
annieyw pushed a commit that referenced this issue Apr 2, 2021
…ly (#22139)

Combines `mat-vertical-stepper` and `mat-horizontal-stepper` into a single `mat-stepper`
class in order to allow for the orientation to be changed dynamically. Also deprecates
`MatVerticalStepper` and `MatHorizontalStepper`.

This is a reimplementation of #9173, however this time I took a different approach which should
make it easier to maintain and eventually remove the two separate steppers. It should result in a
smaller bundle as well. The main differences are:

1. Rather than have 3 components (`MatStepper`, `MatVerticalStepper` and `MatHorizontalStepper`),
these changes combine everything into `MatStepper` while `MatVerticalStepper` and
`MatHorizontalStepper` are only used as injection tokens for backwards compatibility. The `selector`
and `exportAs` of `MatStepper` is changed to match the two individual steppers and the orientation
is inferred from the tag name. This will make it much easier to remove the deprecated directives.
Furthermore, it should result in a smaller bundle since the template and styles only need to be
inlined in one place.
2. `MatVerticalStepper` and `MatHorizontalStepper` are turned into very basic directives that have
the same public API as `MatStepper` and they proxy everything to it. This is primarily so that if
somebody managed to get a hold of a `MatVerticalStepper` or `MatHorizontalStepper` instance, or
they used the old classes to type their own code, it wouldn't result in a breaking change.

Relates to #7700.
@crisbeto
Copy link
Member

crisbeto commented Apr 23, 2021

I believe that most of the suggestions here are now supported. I'll close the issue since these sorts of multi-feature-request issues tend to be difficult to follow.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: cdk/stepper feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests