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 needs a beforeSelectionChange event #30292

Open
gmurph52 opened this issue Jan 8, 2025 · 1 comment
Open

Mat Stepper needs a beforeSelectionChange event #30292

gmurph52 opened this issue Jan 8, 2025 · 1 comment
Labels
area: material/stepper feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions

Comments

@gmurph52
Copy link

gmurph52 commented Jan 8, 2025

Feature Description

There should be an event that is triggered when you attempt to navigate to a different step via the mat stepper header.

Currently, there is only a selectionChange event that doesn't get triggered until after the next navigation takes place.

Use Case

In my scenario, when a user attempts to navigate to the next step, I need to first call an endpoint to validate the data they entered. Once I have validated that the data is correct, I can proceed to the next step with stepper.next(). This works as expected if the user clicks on my next button with a custom (click) event, but if they click on the header to navigate, there is no way to call the endpoint before navigation.

Using selectionChange does not work, because there is no way to prevent navigation after the StepperSelectionEvent has happened.

Alternatively, instead of a beforeSelectionChange event, if there were a way to prevent the next navigation when subscribing to the selectionChange event, that would also work. Or if there was a way to prevent navigation from the header, but still capture clicks, so that stepper.next could manually be called.

@gmurph52 gmurph52 added feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team labels Jan 8, 2025
@crisbeto crisbeto added P4 A relatively minor issue that is not relevant to core functions area: material/stepper and removed needs triage This issue needs to be triaged by the team labels Jan 21, 2025
@crisbeto
Copy link
Member

For what it's worth, you should be able to get this to work by doing your validation in an async validator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/stepper feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

2 participants