Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,18 @@ export function useDragDrop(options: UseDragDropOptions = {}) {
siblingsCacheRef.current.clear()
}, [])

useEffect(() => {
if (!isDragging) return
const container = scrollContainerRef.current
if (!container) return
const onLeave = (e: DragEvent) => {
const related = e.relatedTarget as Node | null
if (!related || !container.contains(related)) handleDragEnd()
}
container.addEventListener('dragleave', onLeave)
return () => container.removeEventListener('dragleave', onLeave)
}, [isDragging, handleDragEnd])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d2270a6. Configure here.


const setScrollContainer = useCallback((element: HTMLDivElement | null) => {
scrollContainerRef.current = element
}, [])
Expand Down
Loading