Skip to content

Reactive Form is disabled but disabled property is false #31924

@lukbdevlab

Description

@lukbdevlab

🐞 bug report

Affected Package

The issue is caused by package @angular/forms

Description

I have simple reactive form with some input fields.
The method form.disable() is called to disable the form and all fields.
The method works, as all input fields in the UI are now disabled.

Expected
The property form.disabled should be true as the form is disabled now.

Actual
The property form.disabled is false.

Cause of the problem
After building the form, I subscribe to control f1 and update the value of another control whenever f1 changes.

this.myForm.controls.f1
  .valueChanges
  .subscribe(() => this.testMethod());

testMethod() {
  this.myForm.controls.f3.setValue('test');
}

Workaround
It works when I call form.disable() twice.

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-issue-repro2-g8725l

🌍 Your Environment

Angular Version:




Angular CLI: 7.3.5
Node: 10.14.1
OS: win32 x64
Angular: 7.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.13.5
@angular-devkit/build-angular      0.13.5
@angular-devkit/build-optimizer    0.13.5
@angular-devkit/build-webpack      0.13.5
@angular-devkit/core               7.3.5
@angular-devkit/schematics         7.3.5
@angular/cdk                       7.3.4
@angular/cli                       7.3.5
@angular/material                  7.3.4
@angular/material-moment-adapter   7.3.4
@ngtools/webpack                   1.10.2
@schematics/angular                7.3.5
@schematics/update                 0.13.5
rxjs                               6.4.0
typescript                         3.2.4
webpack                            4.29.6

Stackblitz uses Angular 6.1.9

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions