Components: Stepper: Go to next step using enter key

Created on 12 Jan 2018  路  3Comments  路  Source: angular/components

Bug, feature request, or proposal:

I would like to know if it is possible to use enter key to go to next step & submit form.

What is the expected behavior?

Fill the step, press enter, go to next step
Complete all steps, press enter, submit the form.

What is the current behavior?

https://stackblitz.com/angular/vnqarakmxkx
When I filled the step 1, pressed enter, stepper navigated to 2nd step.
When I filled the step 2, pressed enter, stepper navigated back to 1st step.

What are the steps to reproduce?

Providing a StackBlitz/Plunker (or similar) is the best way to get the team to see your issue.

Plunker starter (using on @master): https://goo.gl/uDmqyY

StackBlitz starter (using latest npm release): https://goo.gl/wwnhMV

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

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

Is there anything else we should know?

has pr

Most helpful comment

That's possible. By default, both buttons in the second step are submit buttons. If you set type="button" on the back button, the next button will be triggered on enter press.

<button type="button" mat-button matStepperPrevious>Back</button>
<button type="submit" mat-button matStepperNext>Next</button>

I think it would make sense to always treat matStepperPrevious as normal buttons, and always set type="submit" for buttons with matStepperNext.

All 3 comments

That's possible. By default, both buttons in the second step are submit buttons. If you set type="button" on the back button, the next button will be triggered on enter press.

<button type="button" mat-button matStepperPrevious>Back</button>
<button type="submit" mat-button matStepperNext>Next</button>

I think it would make sense to always treat matStepperPrevious as normal buttons, and always set type="submit" for buttons with matStepperNext.

Thanks @DevVersion
The Enter key works perfectly after adding button type.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

savaryt picture savaryt  路  3Comments

vanor89 picture vanor89  路  3Comments

theunreal picture theunreal  路  3Comments

vitaly-t picture vitaly-t  路  3Comments

MurhafSousli picture MurhafSousli  路  3Comments