Skip to content

Commit 3e51e1c

Browse files
waleedlatif1claude
andcommitted
fix(tables): Shift+Space preserves anchor for continued keyboard use
Previously Shift+Space cleared selectionAnchor, making all subsequent keyboard shortcuts (arrows, enter, tab) inoperable until a cell was clicked. Now it preserves the anchor and only clears focus, so users can arrow-navigate and Shift+Space to toggle multiple rows in sequence. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 29c765c commit 3e51e1c

File tree

1 file changed

+18
-17
lines changed
  • apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table

1 file changed

+18
-17
lines changed

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,24 @@ export function Table({
718718
return
719719
}
720720

721+
if (e.key === ' ' && e.shiftKey) {
722+
const a = selectionAnchorRef.current
723+
if (!a || editingCellRef.current) return
724+
e.preventDefault()
725+
setSelectionFocus(null)
726+
setCheckedRows((prev) => {
727+
const next = new Set(prev)
728+
if (next.has(a.rowIndex)) {
729+
next.delete(a.rowIndex)
730+
} else {
731+
next.add(a.rowIndex)
732+
}
733+
return next
734+
})
735+
lastCheckboxRowRef.current = a.rowIndex
736+
return
737+
}
738+
721739
const anchor = selectionAnchorRef.current
722740
if (!anchor || editingCellRef.current) return
723741

@@ -773,23 +791,6 @@ export function Table({
773791
return
774792
}
775793

776-
if (e.key === ' ' && e.shiftKey) {
777-
e.preventDefault()
778-
setSelectionAnchor(null)
779-
setSelectionFocus(null)
780-
setCheckedRows((prev) => {
781-
const next = new Set(prev)
782-
if (next.has(anchor.rowIndex)) {
783-
next.delete(anchor.rowIndex)
784-
} else {
785-
next.add(anchor.rowIndex)
786-
}
787-
return next
788-
})
789-
lastCheckboxRowRef.current = anchor.rowIndex
790-
return
791-
}
792-
793794
if (e.key === 'Tab') {
794795
e.preventDefault()
795796
setCheckedRows((prev) => (prev.size === 0 ? prev : EMPTY_CHECKED_ROWS))

0 commit comments

Comments
 (0)