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: table columns collapse when cells are merged #6624

Open
patrick-atticus opened this issue Sep 12, 2024 · 1 comment
Open

Bug: table columns collapse when cells are merged #6624

patrick-atticus opened this issue Sep 12, 2024 · 1 comment
Labels
tables Relates to Lexical Tables

Comments

@patrick-atticus
Copy link
Contributor

This a bug in the playground, but is relevant to anyone trying to implement table resizing.

Screen.Recording.2024-09-12.at.1.37.18.PM.mp4

Merging cells collapses the column width, which is not restored when unmerging (unlike google docs).

Lexical version: v0.17.1

Steps To Reproduce

  1. create a single row table
  2. resize the cells to have some custom widths
  3. merge all the cells together
  4. unmerge

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

  • Low severity
  • Any user implementing tables would benefit from improvements
  • Fix would contribute to the overall quality of tables in lexical
@etrepum etrepum added the tables Relates to Lexical Tables label Sep 12, 2024
@etrepum
Copy link
Collaborator

etrepum commented Sep 12, 2024

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).

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