Skip to content

Commit 4fb659b

Browse files
improvement(tables): drop dead position tracking from paste undo path
1 parent 85d60ea commit 4fb659b

2 files changed

Lines changed: 0 additions & 8 deletions

File tree

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/table-grid.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,14 +2725,10 @@ export function TableGrid({
27252725

27262726
const currentCols = columnsRef.current
27272727
const currentRows = rowsRef.current
2728-
// Captured once before the loop so each new row in the batch gets a unique,
2729-
// sequential position via `+ (newRowIndex - currentRows.length)` below.
2730-
const lastRowPosition = currentRows.reduce((max, r) => Math.max(max, r.position), -1)
27312728

27322729
const undoCells: Array<{ rowId: string; data: Record<string, unknown> }> = []
27332730
const updateBatch: Array<{ rowId: string; data: Record<string, unknown> }> = []
27342731
const createBatchRows: Array<Record<string, unknown>> = []
2735-
const createBatchPositions: number[] = []
27362732

27372733
for (let r = 0; r < pasteRows.length; r++) {
27382734
const targetArrayIndex = currentAnchor.rowIndex + r
@@ -2764,7 +2760,6 @@ export function TableGrid({
27642760
updateBatch.push({ rowId: existingRow.id, data: rowData })
27652761
} else {
27662762
createBatchRows.push(rowData)
2767-
createBatchPositions.push(lastRowPosition + 1 + (targetArrayIndex - currentRows.length))
27682763
}
27692764
}
27702765

@@ -2788,14 +2783,12 @@ export function TableGrid({
27882783
const createdRows = response?.data?.rows ?? []
27892784
const undoRows: Array<{
27902785
rowId: string
2791-
position: number
27922786
data: Record<string, unknown>
27932787
}> = []
27942788
for (let i = 0; i < createdRows.length; i++) {
27952789
if (createdRows[i]?.id) {
27962790
undoRows.push({
27972791
rowId: createdRows[i].id,
2798-
position: createBatchPositions[i],
27992792
data: createBatchRows[i],
28002793
})
28012794
}

apps/sim/stores/table/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export type TableUndoAction =
4040
type: 'create-rows'
4141
rows: Array<{
4242
rowId: string
43-
position: number
4443
orderKey?: string
4544
data: Record<string, unknown>
4645
}>

0 commit comments

Comments
 (0)