lexical: Bug: Cannot toggle editor isEditable using react + react-dom v19 beta
Lexical version: v0.14.5
Steps To Reproduce
- install react + react-dom v19 beta (latest dependency string is
9.0.0-beta-5d29478716-20240506) - use
editor.setEditable()API to toggle editable state
Link to code example:
https://stackblitz.com/~/github.com/acusti/lexical-rich-toggle-editable
if you switch the initial isEditable value from false to true, the editor’s content editable DOM element will remain always contenteditable="true"
if you swap the react + react-dom dependency strings from the v19 beta to v18.3.1, the example behaves correctly
(note that i had to update the npm install script to npm install --legacy-peer-deps in order to prevent issues with lexical’s peer dependencies that specify react 18.x, but that configuration change is already applied in the stackblitz code example above)
The current behavior
the contenteditable state of the editor’s <ContentEditable /> component never changes from its initial value, even when editor.setEditable() is called with a changed value. this is because the registered editable listener is never invoked, though when i create a local listener via initialConfig’s editorState callback, that listener is invoked every time the editor’s editable state changes.
The expected behavior
i expect the ContentEditable component to get the update editable state, as occurs when not using the v19 beta.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (8 by maintainers)
@StyleT yes, I think it’s probably already an issue for next.js that we have had reports about but I think people just did their workarounds (disabling strict mode probably) and left it alone. Currently looking at a fix, I think it is probably as simple as switching to useState, should have a PR to start testing today