Skip to content

Issue with using @for built-in template syntax while removing dynamic form array elements #56467

@sandeepsuvit

Description

@sandeepsuvit

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

No

Description

I was trying to use the new build-in template syntax @for in one of my projects for creating dynamic form array elements. I have also added an option to delete the form array items in the code using which we can remove the items added in the form array. When I create, for example 3 items in the form array and then removing the 2nd element programatically from the list, then the last element is always getting deleted and not the one which I intended to delete.

  1. Screenshot 2024-06-15 at 5 12 48 PM
  2. Screenshot 2024-06-15 at 5 13 16 PM
  3. image

I deleted the Sub task 2 but its showing as Sub task 3 got removed from ui. The json data however shows the form value correctly. Its mainly the ui thats causing the confusion, not sure if this is a two-way binding issue or something

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-svsq3t

Please provide the exception or error you saw

There are no exceptions in the console, but the order of the element remaining after deleting isn't correct or at-least it isn't correctly displayed in the ui

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 18.0.1
Node: 20.13.1
Package Manager: npm 10.8.0
OS: darwin x64

Angular: 18.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1800.1
@angular-devkit/build-angular   18.0.1
@angular-devkit/core            18.0.1
@angular-devkit/schematics      18.0.1
@angular/cli                    18.0.1
@schematics/angular             18.0.1
rxjs                            7.8.1
typescript                      5.4.5
zone.js                         0.14.6

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions