-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
fix(forms): Multiple formControlName directives using the same FormControl do not stay in sync #53668
base: main
Are you sure you want to change the base?
Conversation
5b832d4
to
70061ea
Compare
* @private | ||
*/ | ||
private _syncControlValuesUnderSameFormGroup(newValue: any): void { | ||
if (this._parent instanceof FormGroupDirective) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might also want to supporte the FormArrayDirective
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
took in account
private _syncControlValuesUnderSameFormGroup(newValue: any): void { | ||
if (this._parent instanceof FormGroupDirective) { | ||
this._parent.directives.forEach((dir: FormControlName) => { | ||
const sameControlReference = dir!.control === this.control; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the non null assertion isn't necessary here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
took in account
…ntrol do not stay in sync When other controls share the same form control reference Fixes angular#51239
70061ea
to
1ba8543
Compare
I agree in principle that this would be a nice fix, but it's certain to be a significant breaking change (as is frequently the case with Forms changes). I could run a Google global presubmit to find out how bad the breakage is though. |
Is there any news on this? We're currently trying to refactor a part of our application that would require this fix. Nothing really pressing, so no need to hurry here, but it would help us out tremendously! |
When other controls share the same form control reference
Fixes #50957