fix(ui): stop scrolling on leaving workflow sidebar for drag-drop#4139
fix(ui): stop scrolling on leaving workflow sidebar for drag-drop#4139TheodoreSpeaks wants to merge 2 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryLow Risk Overview When a drag is active, the hook now listens for Reviewed by Cursor Bugbot for commit 6035091. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR adds a Confidence Score: 5/5Safe to merge — the fix is minimal, correctly scoped, and idempotent. The new No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Browser
participant ScrollContainer
participant useDragDrop
User->>Browser: Drag file/item over sidebar
Browser->>ScrollContainer: dragover event
ScrollContainer->>useDragDrop: initDragOver() → isDragging = true
useDragDrop->>useDragDrop: useEffect attaches dragleave listener
loop Auto-scroll loop (while isDragging)
useDragDrop->>ScrollContainer: requestAnimationFrame(handleAutoScroll)
end
User->>Browser: Drag cursor leaves container boundary
Browser->>ScrollContainer: dragleave (relatedTarget = null or outside)
ScrollContainer->>useDragDrop: onLeave() → !container.contains(related)
useDragDrop->>useDragDrop: handleDragEnd() → isDragging = false
useDragDrop->>useDragDrop: useEffect cleanup removes dragleave listener
useDragDrop->>ScrollContainer: cancelAnimationFrame (auto-scroll stops)
Reviews (1): Last reviewed commit: "fix(ui): stop scrolling on leaving workf..." | Re-trigger Greptile |
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-drag-drop.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d2270a6. Configure here.
| } | ||
| container.addEventListener('dragleave', onLeave) | ||
| return () => container.removeEventListener('dragleave', onLeave) | ||
| }, [isDragging, handleDragEnd]) |
There was a problem hiding this comment.
Full drag state reset corrupts re-entry behavior
Medium Severity
The dragleave handler calls handleDragEnd() which resets all drag state — including draggedSourceFolderRef, dropIndicatorRef, and siblingsCacheRef. But the browser's native drag operation continues (user is still holding the mouse). If the cursor re-enters the container, initDragOver re-sets isDragging to true, but draggedSourceFolderRef stays null. This causes isSameFolder/isSameParent checks in createWorkflowDragHandlers and createFolderDragHandlers to return incorrect results, leading to wrong drop indicators and potentially incorrect item reordering for non-root items.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d2270a6. Configure here.


Summary
Currently dragging and dropping a file past a scrollable workflow sidebar causes the sidebar to continuously scroll. Switched this to stop scrolling on leaving the container to prevent the issue.
Type of Change
Testing
Checklist
Screenshots/Videos