mdx-editor / editor

A rich text editor React component for markdown
https://mdxeditor.dev
MIT License
1.65k stars 133 forks source link

[BUG] Can't focus NestedLexicalEditor within Table Cell, changes within nested editor do not save #528

Closed mlequime closed 4 days ago

mlequime commented 3 weeks ago

If you want to ask for support or request features, sponsor the project and contact me over email.

Describe the bug NestedLexicalEditors within a table cell in the tablePlugin can't be focused. When the focus event is added, the changes within the editor do not save, apparently due to the table cell

Reproduction https://codesandbox.io/p/sandbox/mdx-editor-base-forked-qk7m7s?file=%2Fsrc%2FApp.tsx%3A34%2C67

NB: The table plugin is throwing an error even with the example in 3.0+ within codesandbox, so this is using version 2.9. This is reproducible however in 3.8.1.

To Reproduce Steps to reproduce the behavior:

  1. Try to interact with the blue-bordered nestedlexicaleditor within the table cell.
  2. Try to change the value and blur the nested editor.

Expected behavior It should be possible to focus and edit the value, and changes to the nestededitor should propagate up.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context I've investigated two potential fixes. The first is registering a focus handler to the NestedLexicalEditor, the second is either lowering the priority of the BLUR command in the TableEditor, or raising the priority of the BLUR command in the NestedLexicalEditor to match.

petyosi commented 3 weeks ago

That's a valid problem, I need to think about solving it correctly, maybe your solution is right.