Stepper shows edit icons instead of "done" icons
Completed steps should have a "done" icon on a linear stepper.
Completed steps show an edit icon
https://angular-19juam.stackblitz.io
The checkmark makes it easier to understand that a step is done. Perhaps the edit icon is still useful for :hover
and :focus
. Or perhaps the edit icon would work better on a non-linear stepper.
Current build: 5.0.0-rc.3-05d726d
On the issue #7260, it was marked as fixed but the stepper doesn't meet the material guidelines yet, and this is one of the reasons why.
@mmalerba
Any update on this yet?
Temporary CSS fix:
.mat-step-header {
[ng-reflect-ng-switch="edit"].mat-step-icon {
background: green;
.mat-icon.material-icons.ng-star-inserted {
color: green;
position: relative;
left: -15px;
&::before {
content: 'check';
color: #fff;
position: relative;
left: 15px;
font-weight: bold;
}
}
}
}
It is now possible to override the edit and done icons using the matStepperIcon
directive. Usage shown here: https://stackblitz.com/edit/angular-19juam-mwzov3?file=app/stepper-overview-example.html
I'm lowering the priority on this issue since its easy for the user to customize, but leaving it open because I agree that this may not be the most intuitive default experience.
@mmalerba It's nice that you can override the edit
state icon but it's actually completely unclear what the edit
state and done
state represent. I can not get any step into the done
state, no matter if linear, optional,completed or not.
There is documentation needed about how to mark a state as 'done'.
Also I am missing some kind of error
state for a step. Is there an issue I can follow?
@kuhnroyal
@mmalerba Nice, thanks, will follow these issues.
Those edit icons have truly been a pain. 馃槗
I am trying to create a non-linear stepper.
First of, this does not make visual sense:
I lose the numbers and I just have edit icons.
In order to keep the numbers and not have the edit icons, I need to mark each step as not completed:
<mat-step [completed]="false">
<!-- step contents... -->
</mat-step>
Now I get this:
Beautiful!
Well now what if I want to make the step completed so that it can show the check icon!?!?!?
I mark the step completed and navigate to the next step like this:
completeItem() {
this.stepper.selected.completed = true;
this.stepper.next();
}
Now I get the freakin' edit icon again 馃槄! (And I can't mark the step as not editable because then I won't be able to click on it, and I would like to)
So... I guess I should just override the edit icon to the check icon:
<ng-template matStepperIcon="edit">
<mat-icon>check</mat-icon>
</ng-template>
Awesome!!!
But now, I would like to always have the check icon displayed (when step is completed), even when I am currently on that step. So for example, if I am currently on the Business step and it is completed, it should have a check icon, not the number of the step.
Does anyone have a solution for this?
On another note, I would like to back up @Goodwine's idea of enabling the edit icon on :hover
and/or :focus
.
I may be little late, but this might help you. Working good for me.
<ng-template matStepperIcon="edit" let-index="index">
{{index + 1}}
</ng-template>
@arodr967 I absolutely agree with you. Especially with the last case you have encountered.
But now, I would like to always have the check icon displayed (when step is completed), even when I am currently on that step. So for example, if I am currently on the Business step and it is completed, it should have a check icon, not the number of the step.
So according to the Material UI Guidelines, it seems like when a step is completed and you click back into it, it will just show the number. Right now that is how it is coded in this PR https://github.com/angular/material2/pull/11457.
Thanks for investigating this @arodr967 - without your post I would've given up on this component. The behaviour of the stepper icons are still completely broken/identical to what you posted back in April. Using @angular/material 7.1
.
The workarounds required here are silly - when is this going to be fixed?
Hey @hevans90! The stepper should be able to work with that behavior by injecting the following injection token to your component or module:
{
provide: MAT_STEPPER_GLOBAL_OPTIONS,
useValue: { displayDefaultIndicatorType: false }
}
This talks about how to add custom states but it will also give the stepper this new behavior.
<ng-template matStepperIcon="edit" let-index="index">
<mat-icon *ngIf="notes[index].pristine || (notes[index].dirty && notes[index].value.length == 0)">edit</mat-icon>
<mat-icon *ngIf="notes[index].dirty && notes[index].value.length > 0">done</mat-icon>
</ng-template>
This is my solution: just use an array to map some resource that define the state of every step and switch the icons accordly.
This works well enough for me...
<ng-template matStepperIcon="edit">
<mat-icon>done</mat-icon>
</ng-template>
Set the displayDefaultIndicatorType option to false to get rid of edit icons for completed steps:
@NgModule({
providers: [
{
provide: STEPPER_GLOBAL_OPTIONS,
useValue: { displayDefaultIndicatorType: false }
}
]
})
And if you want to show a "done" icon for the final step which was my case:
_Option one: final step is set editable and done icon is shown when the step is active, overwrite edit icon_
_Option two: final step is set not editable and done icon is always shown, overwrite number icon_
Below is the code for the first option, just replace the icon name for the second option.
<ng-template matStepperIcon="edit" let-index="index" let-active="active">
<mat-icon *ngIf="index === stepper.steps.length - 1; else default">done</mat-icon>
<ng-template #default>{{index + 1}}</ng-template>
</ng-template>
_Angular Material 8.2.3._
It works for me. I was able to override pencil icon and display done icon by just adding below code just after stepper tag and outside of mat-step tag.
Refer below code for reference.
<mat-horizontal-stepper #stepper>
<ng-template matStepperIcon="edit">
<mat-icon>check</mat-icon>
</ng-template>
<mat-step>
<ng-template matStepLabel>Make changes</ng-template>
</mat-step>
<mat-step>
<ng-template matStepLabel>Confirm changes</ng-template>
</mat-step>
<mat-step>
<ng-template matStepLabel>Saved</ng-template>
</mat-step>
</mat-horizontal-stepper>
Angular material version 8.2.2.
I came across this when trying to add custom icons to the material stepper. I'm also experiencing this issue. Any idea on how to work around this with custom icons for both the "done" state and also the "edit" state?
Most helpful comment
Those edit icons have truly been a pain. 馃槗
I am trying to create a non-linear stepper.
First of, this does not make visual sense:
I lose the numbers and I just have edit icons.
In order to keep the numbers and not have the edit icons, I need to mark each step as not completed:
Now I get this:
Beautiful!
Well now what if I want to make the step completed so that it can show the check icon!?!?!?
I mark the step completed and navigate to the next step like this:
Now I get the freakin' edit icon again 馃槄! (And I can't mark the step as not editable because then I won't be able to click on it, and I would like to)
So... I guess I should just override the edit icon to the check icon:
Awesome!!!
But now, I would like to always have the check icon displayed (when step is completed), even when I am currently on that step. So for example, if I am currently on the Business step and it is completed, it should have a check icon, not the number of the step.
Does anyone have a solution for this?
On another note, I would like to back up @Goodwine's idea of enabling the edit icon on
:hover
and/or:focus
.