Skip to content

Commit

Permalink
fix: fix currentRow update in updateRow()
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Dec 6, 2024
1 parent 1609a21 commit e99af0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
12 changes: 3 additions & 9 deletions packages/vtable/src/scenegraph/layout/update-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ function removeRow(row: number, scene: Scenegraph, skipUpdateProxy?: boolean) {
if (row >= proxy.rowStart && row <= proxy.rowEnd) {
removeCellGroup(row, scene);
proxy.rowEnd--;
if (!skipUpdateProxy) {
proxy.currentRow--;
}
proxy.currentRow--;
}
if (!skipUpdateProxy) {
proxy.bodyBottomRow--;
Expand All @@ -229,9 +227,7 @@ function addRow(row: number, scene: Scenegraph, skipUpdateProxy?: boolean) {
if (proxy.rowEnd - proxy.rowStart + 1 < proxy.rowLimit) {
// can add row
proxy.rowEnd++;
if (!skipUpdateProxy) {
proxy.currentRow++;
}
proxy.currentRow++;

addRowCellGroup(row, scene);
return row;
Expand All @@ -241,9 +237,7 @@ function addRow(row: number, scene: Scenegraph, skipUpdateProxy?: boolean) {
if (proxy.rowEnd - proxy.rowStart + 1 < proxy.rowLimit) {
// can add row
proxy.rowEnd++;
if (!skipUpdateProxy) {
proxy.currentRow++;
}
proxy.currentRow++;

addRowCellGroup(row, scene);
return row;
Expand Down
16 changes: 8 additions & 8 deletions packages/vtable/src/tools/update-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,34 @@ export function fixUpdateRowRange(
let updateRow = Infinity;

for (let i = 0; i < addCellPositions.length; i++) {
const { row } = addCellPositions[i];
const { row: cellRow } = addCellPositions[i];

if (rowEnd - rowStart + 1 === rowLimit) {
// current row cell is full
if (row >= rowStart && row <= rowEnd) {
updateRow = Math.min(updateRow, row);
if (cellRow >= rowStart && cellRow <= rowEnd) {
updateRow = Math.min(updateRow, cellRow);
}
} else {
// row cell is not full
addCells.push({
col,
row
row: cellRow
});
rowEnd++;
}
}

for (let i = 0; i < removeCellPositions.length; i++) {
const { row } = removeCellPositions[i];
if (row < rowStart || row > rowEnd) {
const { row: cellRow } = removeCellPositions[i];
if (cellRow < rowStart || cellRow > rowEnd) {
continue;
} else if (rowEnd === bodyBottomRow) {
removeCells.push({
col,
row
row: cellRow
});
} else {
updateRow = Math.min(updateRow, row);
updateRow = Math.min(updateRow, cellRow);
}
}

Expand Down

0 comments on commit e99af0b

Please sign in to comment.