Skip to content

Commit f4c8017

Browse files
waleedlatif1claude
andcommitted
fix(tables): prevent Ctrl+D bookmark dialog, batch Delete/Backspace mutations
- Move e.preventDefault() before early returns in Ctrl+D handler so the browser bookmark dialog is always suppressed - Replace per-row mutateRef calls with single batchUpdateRef call in both Delete/Backspace handlers (checked rows and cell selection), consistent with cut and fill-down Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0e720d7 commit f4c8017

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

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

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,7 @@ export function Table({
10611061
const pMap = positionMapRef.current
10621062
const currentCols = columnsRef.current
10631063
const undoCells: Array<{ rowId: string; data: Record<string, unknown> }> = []
1064+
const batchUpdates: Array<{ rowId: string; data: Record<string, unknown> }> = []
10641065
for (const pos of checked) {
10651066
const row = pMap.get(pos)
10661067
if (!row) continue
@@ -1071,7 +1072,10 @@ export function Table({
10711072
updates[col.name] = null
10721073
}
10731074
undoCells.push({ rowId: row.id, data: previousData })
1074-
mutateRef.current({ rowId: row.id, data: updates })
1075+
batchUpdates.push({ rowId: row.id, data: updates })
1076+
}
1077+
if (batchUpdates.length > 0) {
1078+
batchUpdateRef.current({ updates: batchUpdates })
10751079
}
10761080
if (undoCells.length > 0) {
10771081
pushUndoRef.current({ type: 'clear-cells', cells: undoCells })
@@ -1238,10 +1242,10 @@ export function Table({
12381242
}
12391243

12401244
if ((e.metaKey || e.ctrlKey) && e.key === 'd') {
1245+
e.preventDefault()
12411246
if (!canEditRef.current) return
12421247
const sel = computeNormalizedSelection(anchor, selectionFocusRef.current)
12431248
if (!sel || sel.startRow === sel.endRow) return
1244-
e.preventDefault()
12451249
const pMap = positionMapRef.current
12461250
const sourceRow = pMap.get(sel.startRow)
12471251
if (!sourceRow) return
@@ -1280,6 +1284,7 @@ export function Table({
12801284
if (!sel) return
12811285
const pMap = positionMapRef.current
12821286
const undoCells: Array<{ rowId: string; data: Record<string, unknown> }> = []
1287+
const batchUpdates: Array<{ rowId: string; data: Record<string, unknown> }> = []
12831288
for (let r = sel.startRow; r <= sel.endRow; r++) {
12841289
const row = pMap.get(r)
12851290
if (!row) continue
@@ -1293,7 +1298,10 @@ export function Table({
12931298
}
12941299
}
12951300
undoCells.push({ rowId: row.id, data: previousData })
1296-
mutateRef.current({ rowId: row.id, data: updates })
1301+
batchUpdates.push({ rowId: row.id, data: updates })
1302+
}
1303+
if (batchUpdates.length > 0) {
1304+
batchUpdateRef.current({ updates: batchUpdates })
12971305
}
12981306
if (undoCells.length > 0) {
12991307
pushUndoRef.current({ type: 'clear-cells', cells: undoCells })

0 commit comments

Comments
 (0)