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
Add unordered list
Click on the top list element
Add a table
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.
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
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
$generateHtmlFromNodes
function it will contain an empty<ul>
tagLink 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.https://github.com/user-attachments/assets/4858287e-071a-484e-803b-05117e99fc88
The current behavior
Table gets added above the list item and exported HTML contains an empty
<ul>
tagThe expected behavior
Table gets added below the list item and exported HTML does not contain a empty
<ul>
tagImpact of fix