Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table inside a NestedLexicalEditor doesn't update properly [BUG] #451

Closed
2 tasks done
oliver-crowe-bp opened this issue May 8, 2024 · 1 comment
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@oliver-crowe-bp
Copy link
Contributor

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

Describe the bug
When a table is added inside a NestedLexicalEditor, the table cell contents does not update in the source mode until a space outside of the table is clicked within the NestedLexicalEditor. This means saved content can be lost when updating a table which is inside a NestedLexicalEditor.

To Reproduce

  1. Add a component which uses a NestedLexicalEditor to the MDXEditor (e.g. anything which uses the GenericJsxEditor with children)
  2. Click within the NestedLexicalEditor and insert a table
  3. Add some text to a cell of the table
  4. Click on the 'source mode' option to view the MDX source
  5. Observe no text appears in the table source (even if you click outside the NestedLexicalEditor)
  6. Click within the NestedLexicalEditor but outside of the table
  7. The table text has now updated in the MDX source

Expected behavior
The table should update when it's changed, and not require an extra click inside the NestedLexicalEditor to trigger an update.

Screenshots
Video demonstration using the GenericJsxEditor and table plugin:

mdx-table-bug.mp4

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: Observed in Chrome, Edge, and Firefox

Additional context
I think this could be because the table editor doesn't dispatch the NESTED_EDITOR_UPDATED_COMMAND when it saves an update, so the NestedLexicalEditor doesn't update itself.

@oliver-crowe-bp oliver-crowe-bp added the bug Something isn't working label May 8, 2024
@petyosi
Copy link
Contributor

petyosi commented May 8, 2024

That's a nasty limitation of Lexical's nested editors, a bit of a chicken-and-egg problem, I'm afraid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants