Skip to content

Commit e64787e

Browse files
committed
fix(tables): guard context-menu delete on stale rows, preserve selection on cancel
- Guard the kind='all' branch on contextRow membership in currentRows (matches the same fix applied to selectedRowCount), so a context menu on a stale row no longer deletes the entire table. - Drop the eager rowSelection clear at modal-open time. The modal's onSuccess already calls handleClearSelection after the mutation resolves, so the post-delete invariant still holds; if the user cancels, the selection is now preserved.
1 parent fa8733c commit e64787e

1 file changed

Lines changed: 3 additions & 4 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: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,9 @@ export function Table({
521521
const currentRows = rowsRef.current
522522
let snapshots: DeletedRowSnapshot[] = []
523523

524-
if (rowSel.kind === 'all') {
524+
const contextRowInRows = currentRows.some((r) => r.id === contextRow.id)
525+
526+
if (rowSel.kind === 'all' && contextRowInRows) {
525527
snapshots = collectRowSnapshots(currentRows)
526528
} else if (rowSel.kind === 'some' && rowSel.ids.has(contextRow.id)) {
527529
snapshots = collectRowSnapshots(currentRows.filter((r) => rowSel.ids.has(r.id)))
@@ -542,9 +544,6 @@ export function Table({
542544

543545
if (snapshots.length > 0) {
544546
setDeletingRows(snapshots)
545-
if (rowSel.kind !== 'none') {
546-
setRowSelection(ROW_SELECTION_NONE)
547-
}
548547
}
549548

550549
closeContextMenu()

0 commit comments

Comments
 (0)