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

Reactive forms. formArrayName with formGroupName #23016

Open
Yerkon opened this issue Mar 27, 2018 · 4 comments
Open

Reactive forms. formArrayName with formGroupName #23016

Yerkon opened this issue Mar 27, 2018 · 4 comments
Assignees
Labels
area: forms freq1: low P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix
Milestone

Comments

@Yerkon
Copy link
Contributor

Yerkon commented Mar 27, 2018

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

...
<div *ngSwitchCase="type.Party"
                           [@enterAnimation]
                           (close)="closeRightPart()"
                           formArrayName="parties">
      <div class="col full"
           [formGroupName]="contract.parties.indexOf(selectedParty)">
            <div>
              <div>Some title</div>
              <input type="number"
                     class="full"
                     formControlName="shipmentVolume" /> // shipmentVolume doesn't update
            </div>
             ...
...

parties: FormArray(SomeObject[])
In this code example, I don't iterate over parties. As a content only show some view with form control at specified index. This index of formGroupName changes dynamically and in this cases formControlName value doesn't update. First rendered formControlName value only shown.

Expected behavior

When formGroupName changes need to update formControlName values too.
In my code example selectedParty change, which will trigger to update [formGroupName]

Temporary solution:

Remove this view from template and insert it again with using setTimeout():

 openRightPart(type: Type, selectedParty: Party = null) {
    if (type === Type.Party && selectedParty) {
      setTimeout(() => {
        this.closeRightPart();
      });

      setTimeout(() => {
        this.selectedParty = selectedParty;
        const selectedPart = this.rightParts.find(rp => rp.type === type);
        this.openedPart = selectedPart;
      });


    } else {
      ...
    }
  }

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Angular version: 5.2.5


Browser:
- [ ] 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
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@ngbot ngbot bot added this to the needsTriage milestone Mar 27, 2018
@kara kara added the feature Issue that requests a new feature label May 31, 2018
@ngbot ngbot bot modified the milestones: needsTriage, Backlog May 31, 2018
@houfu
Copy link

houfu commented Jul 31, 2018

Not sure why this is labelled a feature. I thought that with a change in a parent formGroupName, it is expected that child formControlName is also updated. This should be a bug.

The workaround I have developed is to use *ngFor and remove unnecessary items using *ngIf. However this is not intuitive.

@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Jun 4, 2021
@angular-robot
Copy link
Contributor

angular-robot bot commented Jun 4, 2021

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot
Copy link
Contributor

angular-robot bot commented Jun 24, 2021

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@angular-robot angular-robot bot added the feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors label Jun 24, 2021
@dylhunn dylhunn added type: bug/fix and removed feature Issue that requests a new feature feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature: votes required Feature request which is currently still in the voting phase labels Feb 1, 2022
@ngbot ngbot bot modified the milestones: Backlog, needsTriage Feb 1, 2022
@pkozlowski-opensource pkozlowski-opensource added the needs reproduction This issue needs a reproduction in order for the team to investigate further label Sep 21, 2022
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Sep 21, 2022
@JoostK
Copy link
Member

JoostK commented Sep 28, 2022

@JoostK JoostK added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs reproduction This issue needs a reproduction in order for the team to investigate further labels Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: forms freq1: low P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix
Projects
None yet
Development

No branches or pull requests

7 participants