Open patrick-atticus opened 1 week ago
I don't think this is a bug, more like a feature request. Cells don't have a fixed width to them (until set by resize), it's all based on whatever your CSS is configured to do. When cells are merged, only the display metadata (style, background color, width) from the top-left cell is used and all of the other cells' metadata is discarded. Unmerge couldn't restore any of the metadata for any of the other cells because it's not anywhere in the document anymore.
I think at best what you could do, in your app, would be to check the widths before merge to see if anything custom is set. If so, calculate the display width of the merged area before merge and then set it on the result after merge. Unmerging the best you could do is distribute any custom width equally across the top row (and the content would all still be in the top-left cell).
This a bug in the playground, but is relevant to anyone trying to implement table resizing.
https://github.com/user-attachments/assets/7d0b24af-158a-4d71-8cee-27ad845c3f74
Merging cells collapses the column width, which is not restored when unmerging (unlike google docs).
Lexical version: v0.17.1
Steps To Reproduce
The current behavior
Table collapses to the size of a single cell. Unmerging expands to the minimum width
The expected behavior
Table retains it's width but has a single cell. Unmerging should restore previous column widths
Impact of fix