-
Notifications
You must be signed in to change notification settings - Fork 27.1k
ReactiveForms: Changing Validators doesn't trigger recalculation of form/field statuses #28216
Copy link
Copy link
Closed
Labels
Milestone
Description
🐞 bug report
Affected Package
The issue is caused by package @angular/FormsIs this a regression?
Not that I know of.Description
When you change a field's validators inside a form it should recalculate the forms status using the new rules. Currently it seems to stay with whatever status it had before until you touch that field again.My issue is that I have a form with a field that's required when conditions are met, but if those conditions aren't met then I don't even show it to the user. Now if the user doesn't fill out this field and then changes the conditions to make it hidden again, the form is stuck "INVALID" because even though I cleared the validators and hid that control, it still has a status of invalid. Now the user can't do anything to fix the issue and even this.form.errors is empty.
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-issue-repro2-7dhmgp🌍 Your Environment
Angular Version:
Angular CLI: 7.2.1
Node: 11.2.0
OS: win32 x64
Angular: 7.2.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.12.1
@angular-devkit/build-angular 0.12.1
@angular-devkit/build-optimizer 0.12.1
@angular-devkit/build-webpack 0.12.1
@angular-devkit/core 7.2.1
@angular-devkit/schematics 7.2.1
@angular/cdk 7.2.1
@angular/cli 7.2.1
@angular/flex-layout 7.0.0-beta.23
@angular/material 7.2.1
@ngtools/webpack 7.2.1
@schematics/angular 7.2.1
@schematics/update 0.12.1
rxjs 6.3.3
typescript 3.2.2
webpack 4.23.1
Reactions are currently unavailable