Skip to content

Support Angular 15? Issue with setDisabledState #112

@djdmorrison

Description

@djdmorrison

Hello,

Thanks for the Angular wrapper!

We've updated our app to Angular 15 but facing an error with jodit-angular. The package worked fine with Angular 14 so it's a recent update.

The error is Cannot read properties of undefined (reading 'setReadOnly'). This is thrown when setDisabledState() is called.

I believe the breaking change in Angular is the following: "In Angular 15, the setDisabledState is called when a ControlValueAccessor is attached. To avert using the same behavior, use FormsModule.withConfig or ReactiveFormsModule.withConfig."

A quick fix is to add a guard to setDisabledState() to check editor is defined.

setDisabledState(isDisabled: boolean): void {
    if (!this.editor) return; // guard to check if editor is defined.
    this.editor.setReadOnly(isDisabled);
}

I would submit a PR but not sure what else needs changing so just calling out this fix and hoping for a new version soon. Thanks!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions