Skip to content

Commit 87ffb4a

Browse files
committed
fix(tables): re-read live placement before skipping a move as a no-op
`handleMoveTable` and `handleMoveFolder` decided "already there, nothing to do" from `activeTable`/`activeFolder`, which are snapshots taken when the context menu opened. A refetch or a concurrent move since then makes that comparison stale, so the write the user just asked for is silently skipped and the row stays where it was. Both now compare against the live list, matching the knowledge-base move.
1 parent 088801b commit 87ffb4a

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/tables

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,17 @@ export function Tables() {
743743
(optionValue: string) => {
744744
if (!activeTable) return
745745
const folderId = parseMoveOptionValue(optionValue)
746-
if ((activeTable.folderId ?? null) === folderId) return
746+
/**
747+
* Placement is re-read from the live list rather than trusted from `activeTable`, which
748+
* is a snapshot taken when the menu opened. A refetch or a concurrent move since then
749+
* would make the no-op check compare against a stale location and skip a write the user
750+
* asked for. Matches the knowledge-base move.
751+
*/
752+
const current = tablesRef.current.find((table) => table.id === activeTable.id) ?? activeTable
753+
if ((current.folderId ?? null) === folderId) {
754+
closeRowContextMenu()
755+
return
756+
}
747757
moveTable.mutate({ tableId: activeTable.id, folderId })
748758
closeRowContextMenu()
749759
},
@@ -770,11 +780,12 @@ export function Tables() {
770780
(optionValue: string) => {
771781
if (!activeFolder) return
772782
const parentId = parseMoveOptionValue(optionValue)
773-
if ((activeFolder.parentId ?? null) === parentId) return
774-
moveFolderTo(activeFolder.id, parentId)
783+
// Same reasoning as `handleMoveTable`: compare against the live row, not the snapshot.
784+
const current = folderById.get(activeFolder.id) ?? activeFolder
785+
if ((current.parentId ?? null) !== parentId) moveFolderTo(activeFolder.id, parentId)
775786
closeRowContextMenu()
776787
},
777-
[activeFolder, moveFolderTo, closeRowContextMenu]
788+
[activeFolder, folderById, moveFolderTo, closeRowContextMenu]
778789
)
779790

780791
const rowDragDropConfig = useFolderRowDragDrop({

0 commit comments

Comments
 (0)