Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(forms): Multiple formControlName directives using the same FormControl do not stay in sync #53668

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from

Conversation

AnthonyFr75
Copy link
Contributor

@AnthonyFr75 AnthonyFr75 commented Dec 20, 2023

When other controls share the same form control reference

Fixes #50957

@pullapprove pullapprove bot requested a review from AndrewKushnir December 20, 2023 21:01
@AnthonyFr75 AnthonyFr75 force-pushed the my-fix-branch-for-51239 branch 2 times, most recently from 5b832d4 to 70061ea Compare December 20, 2023 21:10
packages/forms/test/reactive_integration_spec.ts Outdated Show resolved Hide resolved
* @private
*/
private _syncControlValuesUnderSameFormGroup(newValue: any): void {
if (this._parent instanceof FormGroupDirective) {
Copy link
Member

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

Copy link
Contributor Author

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;
Copy link
Member

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.

Copy link
Contributor Author

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
@AnthonyFr75 AnthonyFr75 force-pushed the my-fix-branch-for-51239 branch from 70061ea to 1ba8543 Compare December 21, 2023 05:57
@AndrewKushnir AndrewKushnir requested review from dylhunn and removed request for AndrewKushnir January 2, 2024 19:05
@ngbot ngbot bot added this to the Backlog milestone Jan 17, 2024
@dylhunn
Copy link
Contributor

dylhunn commented Jan 17, 2024

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.

@IbenTesara
Copy link

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!

@JeanMeche
Copy link
Member

JeanMeche commented May 18, 2024

We discussed recently with @dylhunn landing some breaking changes behind flags, this could be one of them. (#55761 is another one for example).

Let us investigate this so we can land several forms improvements in the upcoming versions.

crisbeto added a commit to crisbeto/angular that referenced this pull request Nov 8, 2024
Fixes that currently binding the same `formControl` or `formControlName` to the same input doesn't keep the two in sync. Note that this was partially addressed in angular#53668, but it seems like that PR has stalled out and it only addresses `formControlName` and not `formControl`.

Fixes angular#58300.
Fixes angular#51239.
Fixes angular#58522.
@thePunderWoman thePunderWoman marked this pull request as draft May 21, 2025 15:25
@thePunderWoman thePunderWoman removed the request for review from dylhunn June 3, 2025 11:05
@JeanMeche JeanMeche self-assigned this Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FormControls are not usable in multiple formGroups
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.