Skip to content

Commit d4719f3

Browse files
committed
fix(tables): push undo before chunkBatchUpdates to survive partial chunk failures
1 parent c0f878b commit d4719f3

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

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

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,12 +1650,12 @@ export function TableGrid({
16501650
undoCells.push({ rowId: row.id, data: previousData })
16511651
batchUpdates.push({ rowId: row.id, data: updates })
16521652
}
1653-
if (batchUpdates.length > 0) {
1654-
await chunkBatchUpdates(batchUpdates, batchUpdateAsyncRef.current)
1655-
}
16561653
if (undoCells.length > 0) {
16571654
pushUndoRef.current({ type: 'clear-cells', cells: undoCells })
16581655
}
1656+
if (batchUpdates.length > 0) {
1657+
await chunkBatchUpdates(batchUpdates, batchUpdateAsyncRef.current)
1658+
}
16591659
})().catch((error) => {
16601660
logger.error('Failed to clear selected cells', { error })
16611661
toast.error('Failed to clear cells — please try again')
@@ -1881,9 +1881,9 @@ export function TableGrid({
18811881
undoCells.push({ rowId: row.id, data: previousData })
18821882
batchUpdates.push({ rowId: row.id, data: updates })
18831883
}
1884+
if (undoCells.length > 0) pushUndoRef.current({ type: 'clear-cells', cells: undoCells })
18841885
if (batchUpdates.length > 0)
18851886
await chunkBatchUpdates(batchUpdates, batchUpdateAsyncRef.current)
1886-
if (undoCells.length > 0) pushUndoRef.current({ type: 'clear-cells', cells: undoCells })
18871887
})().catch((error) => {
18881888
logger.error('Failed to clear column values', { error })
18891889
toast.error('Failed to clear column values — please try again')
@@ -2058,12 +2058,12 @@ export function TableGrid({
20582058
}
20592059
throw err
20602060
}
2061-
if (cutUpdates.length > 0) {
2062-
await chunkBatchUpdates(cutUpdates, batchUpdateAsyncRef.current)
2063-
}
20642061
if (cutUndo.length > 0) {
20652062
pushUndoRef.current({ type: 'clear-cells', cells: cutUndo })
20662063
}
2064+
if (cutUpdates.length > 0) {
2065+
await chunkBatchUpdates(cutUpdates, batchUpdateAsyncRef.current)
2066+
}
20672067
})().catch((error) => {
20682068
logger.error('Failed to cut selected rows', { error })
20692069
toast.error('Failed to cut — please try again')

0 commit comments

Comments
 (0)