facebook / lexical

Lexical is an extensible text editor framework that provides excellent reliability, accessibility and performance.
https://lexical.dev
MIT License
19.98k stars 1.7k forks source link

Bug: Nested table rows are appended to parent tables when exporting DOM #6749

Open aleksandr-lapushkin opened 1 month ago

aleksandr-lapushkin commented 1 month ago

Lexical version: 0.18.0

Steps To Reproduce

  1. Go to Playground
  2. Insert a 2x2 table
  3. Insert another 2x2 table in any cell.
  4. Export DOM

https://github.com/user-attachments/assets/f27b4087-c7b2-4020-85df-6103894170b6

Link to faulty code: https://github.com/facebook/lexical/blob/b2d57a0162671ab339a3b6bb578218d916ff2131/packages/lexical-table/src/LexicalTableNode.ts#L185

The current behavior

  1. The exported DOM has two tables
  2. The outer table has 4 columns and 4 rows
  3. The nested table has no rows

The expected behavior

  1. The exported DOM has two tables
  2. The outer table has 2 columns and 2 rows
  3. The nested table has 2 rows and 2 columns

    Impact of fix

    Tables cannot be reliably used until this is fixed.

noahnu commented 1 month ago

I can confirm this works in Lexical 0.17.1 but is broken in 0.18.0.

etrepum commented 2 weeks ago

I don't think that nested tables are currently well supported, I'm sure there are a number of related edge cases. If you are interested in this feature I suggest that you look into contributing PRs to implement better tests and support for them.

noahnu commented 2 weeks ago

I don't think that nested tables are currently well supported, I'm sure there are a number of related edge cases. If you are interested in this feature I suggest that you look into contributing PRs to implement better tests and support for them.

FWIW, I've been using nested tables extensively for the past few versions. We haven't had any issues with edge cases until this particular issue. I'd be happy to contribute some test coverage + fixes if @aleksandr-lapushkin doesn't get to it first