Skip to content

Commit 58947a7

Browse files
committed
fix shift-click anchor drift and remove dead stopPropagation constant
- Remove dead stopPropagation const in resource.tsx (replaced by handleSelectRowClick) - Reset lastSelectedIndexRef when visibleRowIds changes so search/filter/folder navigation doesn't leave a stale anchor that produces wrong ranges on the next shift-click - Update lastSelectedIndexRef in handleRowContextMenu when right-clicking resets selection to a single item, so the anchor matches the newly-selected row - Add visibleRowIds to handleRowContextMenu deps (now reads it to compute anchor index) - Remove moveItems.mutateAsync from handleContextMenuMove deps per project convention (.mutateAsync is stable in TanStack v5)
1 parent da80e82 commit 58947a7

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

apps/sim/app/workspace/[workspaceId]/components/resource/resource.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ interface ResourceProps {
9494
const EMPTY_CELL_PLACEHOLDER = '- - -'
9595
const SKELETON_ROW_COUNT = 5
9696

97-
const stopPropagation = (e: React.MouseEvent) => e.stopPropagation()
98-
9997
/**
10098
* Shared page shell for resource list pages (tables, files, knowledge, schedules, logs).
10199
* Renders the header, toolbar with search, and a data table from column/row definitions.

apps/sim/app/workspace/[workspaceId]/files/files.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ export function Files() {
538538
)
539539

540540
useEffect(() => {
541+
lastSelectedIndexRef.current = -1
541542
setSelectedRowIds((prev) => {
542543
const visible = new Set(visibleRowIds)
543544
const next = new Set(Array.from(prev).filter((id) => visible.has(id)))
@@ -1128,11 +1129,12 @@ export function Files() {
11281129
? { kind: 'folder', id: parsed.id, folder: item as WorkspaceFileFolderApi }
11291130
: { kind: 'file', id: parsed.id, file: item as WorkspaceFileRecord }
11301131
if (!selectedRowIds.has(rowId)) {
1132+
lastSelectedIndexRef.current = visibleRowIds.indexOf(rowId)
11311133
setSelectedRowIds(new Set([rowId]))
11321134
}
11331135
openContextMenu(e)
11341136
},
1135-
[folders, openContextMenu, selectedRowIds]
1137+
[folders, openContextMenu, selectedRowIds, visibleRowIds]
11361138
)
11371139

11381140
const handleContextMenuOpen = useCallback(() => {
@@ -1212,7 +1214,7 @@ export function Files() {
12121214
toast.error(toError(error).message)
12131215
}
12141216
},
1215-
[moveItems.mutateAsync, workspaceId, selectedFileIds, selectedFolderIds, closeContextMenu]
1217+
[workspaceId, selectedFileIds, selectedFolderIds, closeContextMenu]
12161218
)
12171219

12181220
const handleContentContextMenu = useCallback(

0 commit comments

Comments
 (0)