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
Reactive forms, async validator issue with delayed observable #44295
Comments
Hi @Maryannah , **Solution : ** Reason : Working Code |
The update on change is there for a reason ... I'm not asking to find a workaround, I know how to do that in at least 3 different ways. What I'm doing is raising a bug on change detection which is not supposed to happen, since everything is scoped in the angular context. |
Hello, any news on that matter ? |
Hello @Maryannah , I think your problem might be in OnPush change detection strategy. During OnPush, there is no change detection performed once your async error is resolved. Would it be okay for you to remove row Another solution (more complex) would be to manually trigger detection, once your asyncValidator is done with validation. |
Hello, I know this is the issue. What I am saying is that it should NOT be an issue. I am running inside Angular's context, which is supposed to be "synced" with the UI. Hence, updating the validation state of a form control should update the UI accordingly. As said, I know how to work around this issue, which I have done (by triggering change detection myself, indeed). What I am asking is to NOT use a workaround, because of the aformentioned reason. |
Hello, |
Hi, I don't know what isn't clear in my previous messages, so I will try another language just in case : Je sais déjà comment contourner le souci, je ne cherche donc pas un moyen de contourner le souci, mais de le résoudre entièrement, car e problème ne devrait pas arriver de base. |
I have the same problem:
I do not understand why this quite basic functionality contains such a bug, while OnPush considered to be more optimized way to organize component flow. P.S. angular v15. Correct me if v16 has it fixed, but this issue is still open. P.P.S. for me decent workaround is to watch form pending state change from true to false and trigger markForCheck on component, cos validation is defined as a common utility method. P.P.P.S. this is so frustrating to copy-paste same logic into every form with async validation: setup pending watcher in onNgInit, check pending on submit and setup waiter for autoretry if form becomes valid after pending |
Any updates since May this year? |
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
Everything can found here :
https://stackblitz.com/edit/angular-ivy-paseta?file=src/app/app.component.ts
Explanation :
When using an async validator with a delayed observable, in a reactive form, with the change detection set to OnPush, the UI does not get updated after the validator has ended its call.
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/angular-ivy-paseta?file=src/app/app.component.ts
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
Screenshots for the lazy ones out there :
First blur :
Second blur :
The text was updated successfully, but these errors were encountered: