Skip to content

Commit e96b1a0

Browse files
committed
fix(tables): capture rowSel before await in delete handler; handle clipboard NotAllowedError
1 parent 8799b9c commit e96b1a0

1 file changed

Lines changed: 23 additions & 3 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: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,9 +1633,9 @@ export function TableGrid({
16331633
if (editingCellRef.current) return
16341634
if (!canEditRef.current) return
16351635
e.preventDefault()
1636+
const rowSel = rowSelectionRef.current
16361637
void (async () => {
16371638
const allRows = await ensureAllRowsLoadedRef.current()
1638-
const rowSel = rowSelectionRef.current
16391639
const currentCols = columnsRef.current
16401640
const undoCells: Array<{ rowId: string; data: Record<string, unknown> }> = []
16411641
const batchUpdates: Array<{ rowId: string; data: Record<string, unknown> }> = []
@@ -1966,7 +1966,17 @@ export function TableGrid({
19661966
toast.error('Clipboard access is unavailable in this context')
19671967
return
19681968
}
1969-
await navigator.clipboard.writeText(lines.join('\n'))
1969+
try {
1970+
await navigator.clipboard.writeText(lines.join('\n'))
1971+
} catch (err) {
1972+
if (err instanceof DOMException && err.name === 'NotAllowedError') {
1973+
toast.error(
1974+
'Clipboard permission expired — press Cmd+C again immediately after selecting'
1975+
)
1976+
} else {
1977+
throw err
1978+
}
1979+
}
19701980
})().catch((error) => {
19711981
logger.error('Failed to copy selected rows', { error })
19721982
toast.error('Failed to copy — please try again')
@@ -2037,7 +2047,17 @@ export function TableGrid({
20372047
toast.error('Clipboard access is unavailable in this context')
20382048
return
20392049
}
2040-
await navigator.clipboard.writeText(lines.join('\n'))
2050+
try {
2051+
await navigator.clipboard.writeText(lines.join('\n'))
2052+
} catch (err) {
2053+
if (err instanceof DOMException && err.name === 'NotAllowedError') {
2054+
toast.error(
2055+
'Clipboard permission expired — press Cmd+X again immediately after selecting'
2056+
)
2057+
} else {
2058+
throw err
2059+
}
2060+
}
20412061
if (cutUpdates.length > 0) {
20422062
await chunkBatchUpdates(cutUpdates, batchUpdateAsyncRef.current)
20432063
}

0 commit comments

Comments
 (0)