Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using disabled property with context watchdog causes a crash #177

Closed
scofalik opened this issue Mar 16, 2020 · 1 comment · Fixed by #179
Closed

Using disabled property with context watchdog causes a crash #177

scofalik opened this issue Mar 16, 2020 · 1 comment · Fixed by #179
Assignees
Labels

Comments

@scofalik
Copy link
Contributor

Watchdog crashes when ckeditor component is initialized with disabled property and watchdog property together.

Below code is fired when disabled property of the component is read:

public setDisabledState( isDisabled: boolean ): void {
	// If already initialized.
	if ( this.editorInstance ) {
		this.editorInstance.isReadOnly = isDisabled;
	}

	// Store the state anyway to use it once the editor is created.
	this.initialIsDisabled = isDisabled;
}

this.editorInstance is a getter:

public get editorInstance(): CKEditor5.Editor | null {
	if ( this.editorWatchdog ) {
		return this.editorWatchdog.editor;
	}

	if ( this.watchdog ) {
		return this.watchdog.getItem( this.id );
	}

	return null;
}

Unfortunately, at the time setDisabledState is called, the editor is not yet added to the watchdog, so this.watchdog.getItem throws an error.

@ma2ciek
Copy link
Contributor

ma2ciek commented Mar 19, 2020

In the next iteration we should close the ckeditor/ckeditor5#6461 and use the new API.

scofalik added a commit that referenced this issue Mar 26, 2020
Fix: Changing `disabled` property on `<ckeditor5>` component while using the watchdog property won't throw an error anymore. Closes #177.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants