Skip to content

A new FormControl instance can disable an input, but it can't enable it #35565

Closed

Description

@sod

Angular 9.0.0

As form controls can disable inputs, it seems like a bug that they can't enable them. Or is it a feature request? It works if you only work with a single FormControl instance. But if you give an disabled input a new FormControl instance, you are stuck.

Reproduction https://ng-run.com/edit/eXsAwaGca33ShZmNXh7v

Click on create enabled FormControl and the input stays enabled. Click at least once on create disabled FormControl, and the enabled control won't kick the input out of the disabled state. And it doesn't inherit the disabled state from the input either.

I guess the disabled state it taken care of in https://github.com/angular/angular/blob/master/packages/forms/src/directives/reactive_directives/form_control_directive.ts#L188-L190, just the reverse is missing.

Activity

  1. changed the title [-]FormControl can disable an input, but it can't enable it[/-] [+]A new FormControl instance can disable an input, but it can't enable it[/+] on Feb 19, 2020
  2. added this to the needsTriage milestone on Feb 19, 2020
  3. navarrofracisco commented on Mar 4, 2020

    @navarrofracisco

    Any update on this? and is it related to? #22556.

    This seems like a huge deal, since reactive forms seem to be preached as the best approach everywhere. Yet I can not disable an input... Any other workarounds?

  4. geromegrignon commented on Mar 4, 2020

    @geromegrignon
    Contributor

    If i understand the problem, the best approach would be not to create a new instance from an already instanciated FormControl. You should use setValue or patchValue if you need to change the value of the FormControl.

  5. sonukapoor commented on Mar 22, 2020

    @sonukapoor
    Contributor

    @petebacondarwin I can take a look at this one. Can you assign it to me please?

  6. mart2k commented on Jul 2, 2020

    @mart2k

    Workaround until fixed:
    <input [formControl]="control" [attr.disabled]="control.disabled? '' : null">

  7. added
    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
    on Oct 23, 2020
  8. modified the milestones: needsTriage, Backlog on Oct 23, 2020
  9. angular-automatic-lock-bot commented on Feb 9, 2021

    @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.

  10. locked and limited conversation to collaborators on Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions