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

🐞[BUG]: ResetForm action side effect completes after the action #2091

Open
symc-gail opened this issue Jan 9, 2024 · 0 comments
Open

Comments

@symc-gail
Copy link

symc-gail commented Jan 9, 2024

Affected Package

The issue is caused by package @ngxs/forms-plugin

Is this a regression?

No (not that i know of)

Description

The ResetForm action completes before the side effects from it (ie resetting the form value) is done.

More background: We had a bug where we were calling reset form, and then waiting on that to finish (ostensibly) before setting some other values to our state. Unfortunately, unless we included delay(1) we were having those other values overwritten by the initial call to ResetForm.

Our suggested fix is to make sure that the reset form action only completes AFTER all the value changes are finished happening, rather than before.

🔬 Minimal Reproduction

https://stackblitz.com/edit/ngxs-forms-bug?file=src%2Fapp%2Fapp.component.ts

This includes a broken version (example 1) and a fixed-with-the-workaround version (example 2). The "set form to (x, y)" is the broken button here.

Environment


Libs:
- @angular/core version: 17.0.7
- @ngxs/store version: 3.8.2

Browser:
I suspect all browsers! I have only tried on chrome desktop though.
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant