No longer crash during destroy()
of MultiRootEditor
or InlineEditor
when the editable was detached manually before destroying.
#17684
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Suggested merge commit message (convention)
Fix (editor-inline, editor-multi-root): No longer crash the editor during
destroy()
when the editable was manually detached before destroying. Closes #16561Additional information
Some editor types check if elements exist before destroying, while others don't. Here's what works correctly:
https://github.com/ckeditor/ckeditor5/blob/ck/16561/packages/ckeditor5-editor-classic/src/classiceditorui.ts#L141-L143
https://github.com/ckeditor/ckeditor5/blob/ck/16561/packages/ckeditor5-editor-balloon/src/ballooneditorui.ts#L102-L104
https://github.com/ckeditor/ckeditor5/blob/ck/16561/packages/ckeditor5-editor-decoupled/src/decouplededitorui.ts#L96-L98
These editors don't have the checks yet:
https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-editor-inline/src/inlineeditorui.ts#L117-L119
https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-editor-multi-root/src/multirooteditorui.ts#L162-L164
This PR adds missing checks to fix crashes in React integration shown here:
View#detachDomRoot()
might operate on non-existing DOM element #16561tl;dr React integration removes editables from DOM just before destroying the editor in Strict Mode. This was causing the multiroot editor to crash.