editor icon indicating copy to clipboard operation
editor copied to clipboard

[BUG] React 18 `Suspense` breaks decorator nodes like tables

Open FarSeeing opened this issue 11 months ago • 2 comments

  • [x] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [x] I have read the documentation and cannot find an answer.

Describe the bug If you wrap the editor into a Suspense component and then something suspends - then after editor gets rendered again all decorator nodes like tables/images wouldn't be shown. ⚠ Happens in React 18 only, version 19 is fine.

Reproduction Start from https://codesandbox.io/p/sandbox/mdx-editor-base-q8s7zr?file=/src/App.tsx to reproduce the problem so that I can observe the issue on my side and make sure that the fix reliably addresses it.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/p/devbox/mdx-editor-base-forked-zwcrn2 (React 18)
  2. Click the "Simulate" button
  3. Verify the table is not shown after re-render
  4. Go to https://codesandbox.io/p/devbox/mdx-editor-base-forked-2ww4lx?workspaceId=ws_3LCuG5GZhcebWgEP9i6HT5 (React 19)
  5. Click the "Simulate" button
  6. Verify the table is shown

Expected behavior Decorators are always shown.

Additional context I'm not entirely sure about the scope of this bug - seems to be caused by the Lexical update happened in 3.11.0 release

FarSeeing avatar Feb 12 '25 11:02 FarSeeing

@FarSeeing I'm not entirely sure about this, but there's some chance this to be a Lexical bug. It would help me a lot if you try to reproduce the problem with a pure lexical editor, maybe there are similar reports in their issues/discord.

petyosi avatar Feb 12 '25 13:02 petyosi

Hey @petyosi I've tried doing the same thing on Lexical playgorund and turns out it works fine with React 18:

https://github.com/user-attachments/assets/c8aecbd1-4314-4302-83d6-784540918051

FarSeeing avatar Feb 17 '25 10:02 FarSeeing