"editor.selection is null" thrown when removing and re-adding editor
See original GitHub issueWhat is the current behavior?
I have two themes in my app: dark & light, and also I have a page in my app that has TinyMCE editor in it and a page that don’t. For the theme switching to work, I had to keep the value of editor in one state, and on theme change, I had to remove the editor from the page, and re-add it later with a little delay. It was the only way that theme switching would work.
Now this theme switching mechanism (removing and re-adding later) caused a problem. whenever I load editor, navigate to another page, and come back later, an error: editor.selection is null
is thrown. Or whenever I toggle theme twice, the same error is thrown. Note that this error is thrown only when I switch pages fast, Or I toggle theme fast
Please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox.io or similar.
https://codesandbox.io/s/dreamy-napier-24xg8?file=/src/App.js
Try moving between
Path1
andPath2
fast, or try clicking onToggle Theme
button fast
What is the expected behavior?
Nothing to be thrown and editor being remounted safely
Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE or tinymce-react
?
Firefox 83
TinyMCE-dev: {"releaseDate": "2020-11-25"}
@tinymce/@tinymce-react: 3.8.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Jira ref: INT-2282
It seems like the editor is getting destroyed after it has started loading stylesheets but before they load. When the stylesheets load they trigger the next step in the editor loading process however the editor has already been destroyed and references to the selection have been cleared.