tinymce / tinymce-angular

Official TinyMCE Angular Component
MIT License
324 stars 93 forks source link

"disabled input" have to has another "input name" #222

Closed denkerny closed 3 years ago

denkerny commented 3 years ago
"@tinymce/tinymce-angular": "^3.6.1"

To avoid scenario angular team wrote:

 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)
      });

it'd be grateful to change:

  @Input()
  public set disabled(val) {
    this._disabled = val;
    if (this._editor && this._editor.initialized) {
      this._editor.setMode(val ? 'readonly' : 'design');
    }
  }

to smth like:

  @Input('isDisabled')
  public set disabled(val) {
    this._disabled = val;
    if (this._editor && this._editor.initialized) {
      this._editor.setMode(val ? 'readonly' : 'design');
    }
  }

And seems like setDisabledState not working for me.

jscasca commented 3 years ago

Hi @kernyden

setDisabledState is an Angular method called when instantiating a FormControl with the disabled property or when calling control.disable()/control.enable(). This is possible because the component uses the NG_VALUE_ACCESSOR provider. That means you don't have to set [disabled]=true on a reactive form directive and instead you can use these the aforementioned methods.

Let me know if this helps

denkerny commented 3 years ago

@jscasca hm, ok. But I do not see people are using disabled property, cause of the reserved keywords.. And yes, setDisabledState from the editor instance and disable() are working with simple demo.

jscasca commented 3 years ago

So, how are you using the disabled mode on the wrapper and does the current behaviour breaks your code in any way?