Skip to content

Reset spanAbove when merging tables to avoid unexpected vertical merge on paste#3399

Open
BryanValverdeU wants to merge 3 commits into
masterfrom
u/bvalverde/skipVerticalSplitsOnMerge
Open

Reset spanAbove when merging tables to avoid unexpected vertical merge on paste#3399
BryanValverdeU wants to merge 3 commits into
masterfrom
u/bvalverde/skipVerticalSplitsOnMerge

Conversation

@BryanValverdeU

Copy link
Copy Markdown
Contributor

Summary

When pasting cells that came from a horizontal split located in the same row as a
vertically split cell, the pasted cells were unexpectedly getting vertically merged.
This resets spanAbove on all incoming source-table cells during a table-into-table
merge, so pasted cells become standalone cells instead of continuations of a vertical merge.

Repro

  1. New mail
  2. Insert a table
  3. Split a cell horizontally > Split another cell vertically in the same row
  4. Input some content in the horizontal split cells
  5. Copy the horizontal split cells and then paste
  6. Observe
    Bug 414670: [Table] Pasting horizontally split cells should not cause the pasted content to merge cells

Actual: The pasted cells were vertically merged.
Expect: Pasting should not cause cells to merge.

Changes

  • mergeModel.ts (mergeTables): reset spanAbove = false on every source cell before merging.
  • mergeModelTest.ts: added test merge source table with spanAbove cells - should reset spanAbove on merged cells.

Testing

yarn test:fast --testPathPattern=mergeModelTest - 64 passing. Verified the new test fails without the fix and passes with it.

BryanValverdeU and others added 2 commits July 14, 2026 12:34
…e on paste

When pasting cells that came from a horizontal split next to a vertically
split cell, the pasted cells were being vertically merged. Reset spanAbove
on all incoming source table cells during a table-into-table merge so pasted
cells become standalone cells instead of continuations of a vertical merge.

Repro:
OS: Win 11
Monarch: 1.2026.226.200 Ring - Dogfood
OWA: 20260227032
- New mail
- Insert a table
- Split a cell horizontally > Split another cell vertically in the same row
- Input some content in the horizontal split cells
- Copy the horizontal split cells and then paste
- Observe

Actual: The pasted cells were vertically merged.
Expect: Pasting should not cause cells to merge.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4f27a803-6207-4fd0-a540-4ab839bbe28a
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://microsoft.github.io/roosterjs/pr-preview/pr-3399/

Built to branch gh-pages at 2026-07-20 21:00 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copilot AI 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.

Pull request overview

This PR fixes an issue in RoosterJS Content Model table paste/merge behavior where pasted cells could incorrectly become part of a vertical merge due to spanAbove being carried over from the source table. The change ensures incoming source-table cells are treated as standalone cells during table-into-table merges.

Changes:

  • Reset spanAbove to false on all source table cells before performing a table-into-table merge.
  • Add a unit test covering the spanAbove reset behavior during table merge.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/roosterjs-content-model-dom/lib/modelApi/editing/mergeModel.ts Resets spanAbove on all incoming source table cells during mergeTables to prevent unintended vertical merges on paste.
packages/roosterjs-content-model-dom/test/modelApi/editing/mergeModelTest.ts Adds a regression test ensuring spanAbove from the source table does not persist after a table merge.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const lastTargetColIndex = getTargetColIndex(table, rowIndex, colIndex, newTableColCount);
const extraColsNeeded = lastTargetColIndex - table.rows[0].cells.length;

newTable.rows.forEach(row => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it possible that newTable really has spanned cells?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is possible, but the current approach follows what Word does, so I propose we go with this for now and listen user feedback in case they want to retain the spanned cells, that is still not the most common scenario though

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hmm ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants