Skip to content

Commit 81f6791

Browse files
waleedlatif1claude
andcommitted
fix(tables): restore width independently of order on delete-column undo, batch fill-down
- Column width restoration in delete-column undo no longer requires previousOrder to be non-null — width is restored independently - Ctrl+D fill-down now uses batchUpdateRef (single API call) instead of calling mutateRef per row in a loop Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c4e5abf commit 81f6791

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,9 +1257,11 @@ export function Table({
12571257
}
12581258
}
12591259
undoCells.push({ rowId: row.id, oldData, newData })
1260-
mutateRef.current({ rowId: row.id, data: newData })
12611260
}
12621261
if (undoCells.length > 0) {
1262+
batchUpdateRef.current({
1263+
updates: undoCells.map((c) => ({ rowId: c.rowId, data: c.newData })),
1264+
})
12631265
pushUndoRef.current({ type: 'update-cells', cells: undoCells })
12641266
}
12651267
return

apps/sim/hooks/use-table-undo.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,19 @@ export function useTableUndo({
228228
}))
229229
batchUpdateRowsMutation.mutate({ updates })
230230
}
231+
const metadata: Record<string, unknown> = {}
231232
if (action.previousOrder) {
232233
onColumnOrderChangeRef.current?.(action.previousOrder)
233-
updateMetadataMutation.mutate({
234-
columnOrder: action.previousOrder,
235-
...(action.previousWidth !== null
236-
? {
237-
columnWidths: {
238-
...(getColumnWidthsRef.current?.() ?? {}),
239-
[action.columnName]: action.previousWidth,
240-
},
241-
}
242-
: {}),
243-
})
234+
metadata.columnOrder = action.previousOrder
235+
}
236+
if (action.previousWidth !== null) {
237+
metadata.columnWidths = {
238+
...(getColumnWidthsRef.current?.() ?? {}),
239+
[action.columnName]: action.previousWidth,
240+
}
241+
}
242+
if (Object.keys(metadata).length > 0) {
243+
updateMetadataMutation.mutate(metadata)
244244
}
245245
},
246246
}

0 commit comments

Comments
 (0)