Skip to content

fix(super-editor): preserve rows without cells when merging - #3845

Merged
caio-pizzol merged 1 commit into
superdoc:v1from
bogdanyluk:fix/3782-merging-multiple-table-rows
Aug 12, 2026
Merged

caio-pizzol merged 1 commit into
superdoc:v1from
bogdanyluk:fix/3782-merging-multiple-table-rows

Conversation

@bogdanyluk

Copy link
Copy Markdown

Fixes #3782

Summary

Fixes table formatting corruption after merging multiple full-width rows in an imported DOCX.

Root cause

ProseMirror represents a full-width vertical merge as:

  • A merged cell with colspan and rowspan
  • An empty continuation row
  • The following normal rows

When serialized, the empty row has no content property. The layout adapter discarded this row, causing the next row to be processed while the merged columns were still occupied. AutoFit then placed its cells in additional columns, widening the table and rendering cells outside its right boundary.

Fix

  • Preserve structurally empty table rows in the layout adapter.
  • Normalize missing row content to an empty array.
  • Keep empty rows in the table’s row timeline so rowspans advance correctly.
  • Continue omitting tables where every row is empty.
  • Add regression coverage for a full-width, multi-row merge followed by a normal row.

Screenshots

Before

зображення

After

зображення

Test Plan

  • Import .docx with a table (from the issue).
  • Confirm the table initially renders with three aligned columns.
  • Select every cell across two or more adjacent blank rows and merge them.
  • Verify the merged cell spans the full table width and both selected rows.
  • Verify all subsequent rows remain aligned to the original three-column grid.
  • Verify no cells protrude beyond the table’s right edge.
  • Undo and redo the merge and confirm the table remains correctly formatted.

ProseMirror's `mergeCells` command can result in table rows that contain
no
cells. Previously, these rows were filtered out during conversion to
`FlowBlock[]`, which could lead to incorrect row counts and rendering
when
a cell with a `rowspan` attribute covered these empty rows.

This change modifies `parseTableRow` to ensure that structurally empty
rows
are preserved, preventing rendering issues with vertically merged cells.

Fixes superdoc#3782

@caio-pizzol caio-pizzol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @bogdanyluk! I reproduced the issue and confirmed that this fix preserves the empty rows covered by the vertical merge. The following rows now stay aligned with the original three-column grid, including after undo and redo. The fix looks good. Approved!

@caio-pizzol
caio-pizzol merged commit 5f4d5ac into superdoc:v1 Aug 12, 2026
49 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merging multiple rows in a table causes formatting issues

2 participants