Skip to content

Commit

Permalink
πŸ›
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeyens committed Dec 16, 2023
1 parent 647a2da commit f73f6b8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/table/src/merge/mergeTableCells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ export const mergeTableCells = <V extends Value = Value>(
for (const entry of cellEntries) {
const [data, path] = entry;

const rowIndex = path.at(-2)!;

// count only those cells that are in the first selected row.
if (path[1] === cellEntries[0][1][1]) {
if (rowIndex === cellEntries[0][1].at(-2)!) {
const cellColSpan = getColSpan(data as TTableCellElement);
colSpan += cellColSpan;
}
Expand Down Expand Up @@ -83,10 +85,13 @@ export const mergeTableCells = <V extends Value = Value>(
if (!hasHeaderCell && entry.type === 'table_header_cell') {
hasHeaderCell = true;
}
if (cols[path[1]]) {
cols[path[1]].push(path);

const rowIndex = path.at(-2)!;

if (cols[rowIndex]) {
cols[rowIndex].push(path);
} else {
cols[path[1]] = [path];
cols[rowIndex] = [path];
}
});

Expand Down

0 comments on commit f73f6b8

Please sign in to comment.