fix(platform): clear the full-page drop overlay after a composer drop#2121
Merged
Merged
Conversation
Dropping a file onto the chat composer left the full-page "Drop files here" overlay (PageDropOverlay / usePageFileDrop) stuck until a manual page reload. The composer's FileUpload.DropZone calls stopPropagation() on its drop so the file lands there — which also stopped the window's bubble-phase drop handler from running, so isDragOver/dragDepth never reset. Reset the overlay state in the CAPTURE phase, which runs window->target BEFORE any child's stopPropagation, so it always fires. The bubble handler still owns the upload for drops that don't hit a region zone (no double-upload). Adds a regression test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Dragging a file onto the chat composer left the full-page "Drop files here to upload" overlay stuck — covering the page and blocking all interaction until a manual reload. The file still attached (the composer handled the drop), but the overlay never dismissed.
Root cause
The full-page overlay is
PageDropOverlay, driven by the window-levelusePageFileDrophook (chat-interface.tsx:480/1159). The chat composer'sFileUpload.DropZonecallse.stopPropagation()on itsdrop(file-upload.tsx:187) so the file lands on the composer rather than the window handler. ButstopPropagation()also prevents the window's bubble-phasedroplistener from ever running — soisDragOver/dragDepthnever reset, and the overlay sticks until reload. The hook's own design note even anticipated the "region zone wins" routing, but missed that the reset then never fires.Fix
Reset the overlay state (
dragDepth = 0; setIsDragOver(false)) in a capture-phase windowdroplistener. The capture phase runs window → target, before any child'sstopPropagation(), so the reset always fires regardless of who handles the drop. The existing bubble-phase handler still owns the upload for drops that don't hit a region zone, so there's no double-upload.Testing
use-page-file-drop.test.ts: drops onto a child element thatstopPropagation()s and asserts (a) the overlay clears and (b) the window handler does not also upload. Fails without the fix, passes with it.app/hooks/use-page-file-drop.test.ts— 5/5 pass · platform tsc 0 · lint 0Notes