From d16bf03e4789b262ae8b7a766ef6335aeebc8ce0 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 22 Jan 2026 18:55:07 -0500 Subject: [PATCH] fix: Row inserted incorrectly with merged first column cells (#11245) closes #11241 --- shared/editor/nodes/TableRow.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shared/editor/nodes/TableRow.ts b/shared/editor/nodes/TableRow.ts index e1a9306f55..9d72086ce7 100644 --- a/shared/editor/nodes/TableRow.ts +++ b/shared/editor/nodes/TableRow.ts @@ -330,7 +330,15 @@ export default class TableRow extends Node { decorations.push(buildAddRowDecoration(pos, index)); } - decorations.push(buildAddRowDecoration(pos, index + 1)); + // Calculate the rowspan of the first column cell to determine the + // correct index for the "add row after" button. When cells are + // merged vertically, we need to insert after all merged rows. + const firstCellNode = + currentFirstCellPos !== undefined + ? doc.nodeAt(currentFirstCellPos) + : null; + const rowspan = firstCellNode?.attrs.rowspan ?? 1; + decorations.push(buildAddRowDecoration(pos, index + rowspan)); } }); }