Skip to content

Creating a new FormGroup instance for the same <form> Element does not initialize disabled states correctly #44478

Closed

Description

@BaggersIO

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

forms

Is this a regression?

No

Description

If a form is initialized multiply times with a new FormGroup, default disabled states of the controls will not apply.

It seems, that the form states (enabled/disabled) are somehow cached in the view. So, as a workaround, I destroyed the view and created a new one. You can see the workaround in the stackblitz, too.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-ivy-6fg5hd?file=src%2Fapp%2Fapp.component.ts

Please provide the exception or error you saw

The view is not rendered correctly / form controls have wrong enabled/disabled states.

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


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 13.1.1
Node: 14.17.2
Package Manager: npm 6.14.13
OS: darwin x64

Angular: 13.1.0
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1301.1
@angular-devkit/build-angular   13.1.1
@angular-devkit/core            13.1.1
@angular-devkit/schematics      13.1.1
@angular/cli                    13.1.1
@schematics/angular             13.1.1
rxjs                            6.6.7
typescript                      4.5.4

Anything else?

The stackblitz example is built with Angular 12, but the same bug appears on a local ng13 project.

Activity

  1. destus90 commented on Dec 14, 2021

    @destus90
    Contributor

    Seems like the work is already underway in this area

    #43499

  2. AndrewKushnir commented on Dec 17, 2021

    @AndrewKushnir
    Contributor

    As @destus90 mentioned above, this issue looks similar to #22556 (with a possible fix in PR #43499), so I'm closing this issue as a duplicate. Please subscribe to #22556 to get further updates. Thank you.

  3. angular-automatic-lock-bot commented on Jan 17, 2022

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  4. locked and limited conversation to collaborators on Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions