ckeditor5-react icon indicating copy to clipboard operation
ckeditor5-react copied to clipboard

Quick rerendering causes editor issues

Open DawidKossowski opened this issue 1 year ago • 1 comments

In StrictMode or in situations where the application quickly rerenders, the next editor instance is rerendered or attempts to rerender before the previous instance is destroyed, especially when the editor uses async calls (for example, for getting the cloud services token).

We've implemented a mechanism to keep track of the destroying promise (editorDestructionInProgress) and to wait for it to resolve before initializing the next editor instance. However, in some cases, the next editor instance is initialized before the previous one starts the destroying process (editorDestructionInProgress is null). This results in two editor instances on the page or in an error: CKEditorError: editor-source-element-already-used. The outcome depends on the integration.

This issue is non-deterministic and depends on the React versions, but it can be reproduced by adding the config with cloudServices property (in our demo: demo-react-18) to trigger a request for a token during editor initialization.

DawidKossowski avatar Apr 18 '24 12:04 DawidKossowski

@Mati365 please check this mechanism in both integrations: CKEditor and useMultiRootEditor.

DawidKossowski avatar Apr 18 '24 12:04 DawidKossowski

Fixed in https://github.com/ckeditor/ckeditor5-react/releases/tag/v7.0.0. Closing as done.

Mati365 avatar Jun 06 '24 06:06 Mati365