Skip to content

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Oct 4, 2024

Fixes a couple of issues with the integration between the CDK stepper and the forms module.

fix(cdk/stepper): remove mock of forms type

Previously we were mocking out the AbstractControl type, because we didn't want to bring in additional code for the optional forms integration. That's no longer necessary, because we can use type-only imports.

fix(cdk/stepper): reset submitted state when resetting stepper

CdkStepper has a reset method that reset all the controls to their initial values, but that won't necessarily put the form into its initial state, because form controls also show errors on submit by default and AbstractControl.reset won't reset the submitted state.

These changes add a call to reset all child forms to their unsubmitted state.

Fixes #29781.

@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label Oct 4, 2024
@crisbeto crisbeto requested a review from a team as a code owner October 4, 2024 08:09
@crisbeto crisbeto requested review from amysorto and andrewseguin and removed request for a team October 4, 2024 08:10
@crisbeto crisbeto added the merge: preserve commits When the PR is merged, a rebase and merge should be performed label Oct 4, 2024
Previously we were mocking out the `AbstractControl` type, because we didn't want to bring in additional code for the optional forms integration. That's no longer necessary, because we can use type-only imports.
`CdkStepper` has a `reset` method that reset all the controls to their initial values, but that won't necessarily put the form into its initial state, because form controls also show errors on submit by default and `AbstractControl.reset` won't reset the submitted state.

These changes add a call to reset all child forms to their unsubmitted state.

Fixes angular#29781.
@crisbeto crisbeto force-pushed the 29781/stepper-reset branch from 6559f66 to 11b7fea Compare October 4, 2024 08:14
@crisbeto crisbeto removed the request for review from amysorto October 4, 2024 12:02
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Oct 4, 2024
@crisbeto crisbeto merged commit 02823c0 into angular:main Oct 4, 2024
21 of 24 checks passed
@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 Nov 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker merge: preserve commits When the PR is merged, a rebase and merge should be performed target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(Stepper): Stepper reset() Method Marks Form Controls as Touched/Dirty, Triggering Validation Errors

2 participants