Skip to content

Commit 3f8b1a7

Browse files
waleedlatif1claude
andcommitted
fix(workflow): avoid duplicate position updates on drag end
Check isInDragOperation before persisting in onNodesChange to prevent duplicate calls. Drag-end events have dragStartPosition still set, while keyboard movements don't, allowing proper distinction. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9634165 commit 3f8b1a7

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,6 +2365,9 @@ const WorkflowContent = React.memo(() => {
23652365

23662366
// Handle position changes (e.g., from keyboard arrow key movement)
23672367
// Update container dimensions when child nodes are moved and persist to backend
2368+
// Only persist if not in a drag operation (drag-end is handled by onNodeDragStop)
2369+
const isInDragOperation =
2370+
getDragStartPosition() !== null || multiNodeDragStartRef.current.size > 0
23682371
const keyboardPositionUpdates: Array<{ id: string; position: { x: number; y: number } }> = []
23692372
for (const change of changes) {
23702373
if (
@@ -2374,15 +2377,22 @@ const WorkflowContent = React.memo(() => {
23742377
change.position
23752378
) {
23762379
updateContainerDimensionsDuringMove(change.id, change.position)
2377-
keyboardPositionUpdates.push({ id: change.id, position: change.position })
2380+
if (!isInDragOperation) {
2381+
keyboardPositionUpdates.push({ id: change.id, position: change.position })
2382+
}
23782383
}
23792384
}
23802385
// Persist keyboard movements to backend for collaboration sync
23812386
if (keyboardPositionUpdates.length > 0) {
23822387
collaborativeBatchUpdatePositions(keyboardPositionUpdates)
23832388
}
23842389
},
2385-
[blocks, updateContainerDimensionsDuringMove, collaborativeBatchUpdatePositions]
2390+
[
2391+
blocks,
2392+
updateContainerDimensionsDuringMove,
2393+
collaborativeBatchUpdatePositions,
2394+
getDragStartPosition,
2395+
]
23862396
)
23872397

23882398
/**

0 commit comments

Comments
 (0)