Skip to content

Commit

Permalink
[lexical-table]: Fix: Delete table row in merge cells
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvinayvk committed Dec 8, 2024
1 parent 8d01b99 commit b7a1e76
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/lexical-table/src/LexicalTableUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ export function $deleteTableRow__EXPERIMENTAL(): void {
return;
}
const columnCount = gridMap[0].length;
const selectedRowCount = anchorCell.__rowSpan;
const nextRow = gridMap[focusEndRow + 1];
const nextRowNode: null | TableRowNode = grid.getChildAtIndex(
focusEndRow + 1,
Expand All @@ -537,7 +538,11 @@ export function $deleteTableRow__EXPERIMENTAL(): void {
}
// Rows overflowing top have to be trimmed
if (row === anchorStartRow && cellStartRow < anchorStartRow) {
cell.setRowSpan(cell.__rowSpan - (cellStartRow - anchorStartRow));
const overflowTop = anchorStartRow - cellStartRow;
cell.setRowSpan(
cell.__rowSpan -
Math.min(selectedRowCount, cell.__rowSpan - overflowTop),
);
}
// Rows overflowing bottom have to be trimmed and moved to the next row
if (
Expand Down

0 comments on commit b7a1e76

Please sign in to comment.