question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"disabled attribute with a reactive form directive" Warning, when using reactive forms with disabled attribute

See original GitHub issue

PLEASE MAKE SURE THAT:

  • you searched similar issues online (9/10 issues in this repo are solved by googling, so please…do it)
  • you provide an online demo I can see without having to replicate your environment
  • you help me by debugging your issue, and if you can’t, do go on filling out this form

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] support request/question

Notice: feature requests will be ignored, submit a PR if you'd like

Current behavior

Using tag-input with reactive form and adding disabled, angular throws the following warning:

<div [formGroup]='group'>
       <tag-input class='form-control'
                  [formControlName]='controlName'
                  [dragZone]='readOnly ? false : widgetProperty.key'
                  [placeholder]='""'
		  [secondaryPlaceholder]='""'
                  [editable]='!readOnly'
                  [disabled]='readOnly'
		  [theme]='"minimal"' ngDefaultControl
                  (onTagEdited)='group.markAsDirty()'>
         <tag-input-dropdown [autocompleteItems]="autocompleteItems">
         </tag-input-dropdown>
       </tag-input>
    </div>

It looks like you’re using the disabled attribute with a reactive form directive. If you set disabled to true when you set up this control in your component class, the disabled attribute will actually be set in the DOM for you. We recommend using this approach to avoid ‘changed after checked’ errors.

  Example: 
  form = new FormGroup({
    first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
    last: new FormControl('Drew', Validators.required)
  });

Expected behavior

It should not throw any warning.

Minimal reproduction of the problem with instructions (if applicable)

What do you use to build your app?. Please specify the version

angular-cli: 1.3.0

Angular version:

4.3.5

ngx-chips version:

1.4.6

Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

all

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

19reactions
Gbuompriscocommented, Nov 5, 2017

The fix should be shipped with v1.5.6. @Zoltamcsak you will need to change the attribute [disabled] to [disable]

1reaction
danielgg93commented, Mar 14, 2018

thanks @Gbuomprisco I had that problem with the disabled but only changed the attribute to disable and everything worked again correctly =)disable="true"

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - Reactive forms - disabled attribute - Stack Overflow
It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true when you set up...
Read more >
Disabling Form Controls When Working With Reactive Forms ...
Instantiate a new FormControl with the disabled property set to true. FormControl({value: '', disabled: true}) . Calling control.disable() or control.enable() .
Read more >
Disable a reactive form control using custom directive - Trung Vo
Solution · 1. Setup the formControl with disabled state · 2. Use FormControl.enable() or FormControl.disable().
Read more >
Disabling Form Controls When Working With ... - Medium
It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true when you set up...
Read more >
How to handle reactive way for disabled property for input e
It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true when you set up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found