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

CKEditor: handle being torn down before initialization #383

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/ckeditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ export default class CKEditor<TEditor extends Editor> extends React.Component<Pr
* @param config CKEditor 5 editor configuration.
*/
private _createEditor( element: HTMLElement | string | Record<string, string>, config: EditorConfig ): Promise<TEditor> {
if ( !element ) {
// In our case, the only way this element is falsy is if we're caught in
// the middle of tearing down this component. This isn't really an error,
// so it doesn't make sense to reject the promise-- that would make the
// watchdog explode anyway. Just create an empty editor so the watchdog
// can shutdown properly.
return this.props.editor.create( '', {} );
}

return this.props.editor.create( element as HTMLElement, config )
.then( editor => {
if ( 'disabled' in this.props ) {
Expand Down