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

Bug: If you add a table on a list it adds it above the list and results in invalid exported HTML #6849

Open
osc245 opened this issue Nov 20, 2024 · 0 comments
Labels
tables Relates to Lexical Tables

Comments

@osc245
Copy link

osc245 commented Nov 20, 2024

If you add an unordered list and then on the list add a table it will add it above the list item and the exported HTML will contain an empty unordered list tag which is invalid HTML.

Lexical version: 0.17.1

Steps To Reproduce

  1. Add unordered list
  2. Click on the top list element
  3. Add a table
  4. Observe the table is above the list element and if you call the $generateHtmlFromNodes function it will contain an empty <ul> tag

Link to code example:

I noticed this in my own app using the INSERT_TABLE_COMMAND command but was able to reproduce it in the Lexical playground so I thought it was easier if I just demoed it using that.

2024-11-20_13-39-41.mp4

The current behavior

Table gets added above the list item and exported HTML contains an empty <ul> tag

The expected behavior

Table gets added below the list item and exported HTML does not contain a empty <ul> tag

Impact of fix

  • This bug seems somewhat but not catastrophically bad. To get around it I need to strip out these empty list elements after exporting the editor content
  • This happens consistently for me, both in my own app and in the Lexical playground. I've just mentioned unordered lists for simplicity but it also applies to ordered lists
  • This seems like a bit of an edge case but as it is general behaviour I think it could benefit lots of users
@etrepum etrepum added the tables Relates to Lexical Tables label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tables Relates to Lexical Tables
Projects
None yet
Development

No branches or pull requests

2 participants