Skip to content

fix: file drop overlay staying active when drag leaves the drop zone - #3023

Open
Vladexy88x wants to merge 3 commits into
cinnyapp:devfrom
Vladexy88x:fix-file-drop-drag-leave
Open

fix: file drop overlay staying active when drag leaves the drop zone#3023
Vladexy88x wants to merge 3 commits into
cinnyapp:devfrom
Vladexy88x:fix-file-drop-drag-leave

Conversation

@Vladexy88x

@Vladexy88x Vladexy88x commented Jul 11, 2026

Copy link
Copy Markdown

Description

Fixes: #2555
The file drop overlay (useFileDropZone) could stay active after the dragged file left the drop zone or the window, because the previous implementation tracked drag state in a ref and only deactivated on dragleave when the last state was over.

This PR replaces the ref-based state tracking with a relatedTarget check in the dragleave handler: the overlay is deactivated when the element being entered is outside the zone, or null (pointer left the window). This also lets us drop the dragStateRef and the bookkeeping in the drop/dragover handlers.

in collaboration Claude Code

Replace the drag-state ref tracking with a relatedTarget check in
dragleave, so the overlay deactivates when the pointer leaves the
zone or the window.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Vladexy88x Vladexy88x changed the title Fix file drop overlay staying active when drag leaves the drop zone fix: file drop overlay staying active when drag leaves the drop zone Jul 11, 2026
@Hifumorenko

Copy link
Copy Markdown

Thank you!

Vladexy88x and others added 2 commits July 28, 2026 23:32
Replace the unchecked `as Node | null` downcast with an `instanceof Node`
check so a non-Node EventTarget cannot make `contains()` throw inside the
listener and strand the overlay active.

Also document the two things the guard silently depends on: relatedTarget
is absent on drag-cancel and on every WebKit dragleave, not just when
leaving the window; and portaled Overlays/PopOuts are never contained by
the zone, so the drop overlay's pointerEvents: 'none' is load-bearing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drag & drop modal gets stuck sometimes

2 participants