Reset spanAbove when merging tables to avoid unexpected vertical merge on paste#3399
Reset spanAbove when merging tables to avoid unexpected vertical merge on paste#3399BryanValverdeU wants to merge 3 commits into
Conversation
…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
…u/bvalverde/skipVerticalSplitsOnMerge
|
There was a problem hiding this comment.
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
spanAbovetofalseon all source table cells before performing a table-into-table merge. - Add a unit test covering the
spanAbovereset 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 => { |
There was a problem hiding this comment.
Is it possible that newTable really has spanned cells?
There was a problem hiding this comment.
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
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
spanAboveon all incoming source-table cells during a table-into-tablemerge, so pasted cells become standalone cells instead of continuations of a vertical merge.
Repro
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): resetspanAbove = falseon every source cell before merging.mergeModelTest.ts: added testmerge 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.