-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
📝 Provide detailed reproduction steps (if any)
- Initialize CKEditor 5 (Classic build) with content that includes an inline image.
- Add a change listener to sync the editor’s content:
editor.model.document.on('change:data', () => {
editorElement.value = editor.getData();
});
- Select the image so that its toolbar is visible (important: selection must be active).
- Call editor.setData('') while the image is still selected.
(Optional Backup the current content:const data = editor.getData();
) - Restore the previous OR set new content:
editor.setData(data);
(v44) - Select the image again. (v45)
CodePen reproduction (v44.3.0): 👉 CodePen – CKEditor 5 fake-selection issue
To trigger the error:
- wait for the CodePen page to finish loading
- select the image so that it's toolbar is displayed
- click the
setData('')
button - click the
restore
button
✔️ Expected result
setData() should safely clear and restore content, regardless of the selection state.
Re-selecting an image after restoring content should not throw an error from the editor.
❌ Actual result
v44.3.0: Calling setData(content) immediately after selecting an image and calling setData('') throws an error.
v45.0.0: setData(content) no longer throws, but selecting the image again after content restore causes an error.
In both cases, the .ck-fake-selection-container
element may persist and contribute to the broken state.
❓ Possible solution
To avoid this I have to manually remove any .ck-fake-selection-container
from the DOM before updating content. This avoids the error but is not an ideal solution.
📃 Other details
- Browser: Latest Chrome and Firefox
- OS: macOS, Windows
- First affected CKEditor version: 44.3.0
- Installed CKEditor plugins: N/A
If you'd like to see this fixed sooner, add a 👍 reaction to this post.