Repository navigation
fix(ui): close open dropdown menu when a file drag enters the window - #13541
Conversation
|
Intent: A file dragged in from the OS while any dashboard dropdown menu is open must reach the chat composer drop zone; the open menu closes when the drag enters the window. |
UX Review (Fable 5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Verify with one real OS drag that the menu vanishing mid-drag reads as normal dismissal, not a glitch — stills cannot show it. [UX-REVIEWED] 69a4ed0 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the pending Frontend Lint & Type Check lane goes green: the ContextMenu wrapper depends on Radix [DESIGN-REVIEWED] 69a4ed0 |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Confirm no out-of-tree edition passes a controlled What this change shipsInventory (5 items) — 5 justifiedIntent: FIX — a file dropped on the chat composer attaches even while a sidebar menu is open (issue #13540; three added tests fail on base).
[FIRST-PRINCIPLES-REVIEWED] 69a4ed0 |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed |
a288c50 to
7203a7a
Compare
|
mechanism: shared hook useCloseOnFileDrag applied to both DropdownMenu and ContextMenu roots
|
|
|
|
7203a7a to
57eef39
Compare
|
self-added: yes
|
|
|
|
Head Note for the record: the Fork Opus 5 Review run for |
|
Bundle Size Gate on
Holding for the budget fix on main; will rebase once it lands. |
|
|
|
|
@NicholasRBowers one ask, when you have a minute: head I will not re-ping; the PR otherwise needs nothing from anyone. |
d6efc53 to
d202127
Compare
d202127 to
b5e3f67
Compare
|
Rebased onto current main (e4e6ed7 -> 75b52f1), same code, one commit: d202127 -> b5e3f67. No code change. Round 5's Fork Opus lane (run 36295526281) died on the CI app's installation rate limit before posting a verdict, so this push re-rolls the lanes. Targeted tests: website/src/test/DropdownMenu.fileDragClose.test.tsx 7/7 pass. |
b5e3f67 to
69a4ed0
Compare
|
Retrigger push b5e3f67 -> 69a4ed0: identical tree (timestamp-only amend), no code change. Round 6 on b5e3f67 passed every CI check and the GPT, Opus, Design, First Principles and Security lanes; the UX lane blocked only because the four evidence screenshots were raw fork-commit URLs its evidence step no longer admits. The PR body now embeds them as GitHub user-attachments URLs; this push lets the UX lane re-judge. |
Problem / Motivation
Goal: Dropping a file onto the chat composer attaches it even when a sidebar menu is open.
Open a sidebar "..." menu (folder, session row, "New chat", filter/sort) or right-click a session row, then drag a file from the OS onto the chat composer. The drop overlay never appears and the file is not attached. Dropping works again only after the menu is closed by hand.
Why it matters
The sidebar is where a user browses while deciding which chat gets the file. Any open menu there silently swallows the drop, with no feedback, so it reads as "drag and drop is broken".
Not a goal
Popover/Selectroots: the four remaining modal sites render inside modal Dialogs that already cover the composer, so closing them would not make a drop reachable; a different fix if ever wanted.modal={false}): that would let an outside click both close a menu and activate the sidebar row under it.ChatInput/ChatDropOverlay.What changed (motivation → approach → change)
website/src/hooks/useCloseOnFileDrag.ts: while a modal menu is open, a windowdragentercarrying files calls the menu's close path.website/src/components/ui/dropdown-menu.tsxandwebsite/src/components/ui/context-menu.tsx:DropdownMenuandContextMenuwrap the RadixRootinstead of re-exporting it and apply the rule.website/src/lib/fileDrag.ts:carriesFiles(dataTransfer), moved out ofChatDropOverlay.tsxso the menu and the drop zone agree on what a file drag is.Symptom: every
<DropdownMenu>and<ContextMenu>in the dashboard is a modal Radix menu. While open, Radix setspointer-events: noneondocument.body. HTML5 drag events honour that property, so nothing under the menu, the composer's drop zone (useChatFileDrop) included, receivesdragoverordrop.Root cause: the menu never dismisses during the drag. Radix closes on an outside
pointerdown, and a native file drag produces none. The drag is lost for as long as the menu stays open.Change: the
dragenterstill reacheswindow(it fires on<html>, which body'spointer-eventscannot hide; Radix's own click-outside dismissal relies on the same fact, since itspointerdownlistener sits on the document). The hook listens there while a modal menu is open and, when the drag carries files, closes the menu through the sameonOpenChange(false)path a click-outside uses.DropdownMenukeeps its controlled (open) and uncontrolled (defaultOpen) forms;ContextMenuopens only by right-click, so its wrapper owns the state and its prop type omitsopen. In-page drags (session rows, folder moves) are ignored;modal={false}menus never block the drop zone and are left alone. The drop zone then picks up the nextdragover. This fixes all 53<DropdownMenu>uses and the sidebar row<ContextMenu>at once; switching the sidebar menus tomodal={false}was rejected because a non-modal menu lets an outside click both dismiss the menu and activate the row beneath it.ChatDropOverlay.tsxonly swaps its privatecarriesFilesfor the shared import.Backwards compatibility
Compatible:
DropdownMenuaccepts the same props as RadixRootand forwards them;ContextMenudropsopen, which no caller passes (a future one gets a type error, not a silent ignore); the only new behavior is an extra close trigger while a modal menu is open.Tests
website/src/test/DropdownMenu.fileDragClose.test.tsx(7 tests):defaultOpenmenu unmounts its content and callsonOpenChange(false)on a windowdragentercarryingFiles;openmenu does the same through itsonOpenChange;text/plain,application/x-kiro-session) leave the menu open;modal={false}menu is left open;ContextMenucloses on a file drag and reportsonOpenChange(false), and ignores an in-page drag.The three dismissal tests fail on
origin/main(content stays mounted,onOpenChangenever called) and pass with this change. ExistingChatDropOverlay.test.tsxandmenuContentOverflow.test.tsxunchanged and green.Manual verification
Real Chromium against a harness gateway (
spawn_feature_gateway(fixture="minimal")) serving this head's builtdist. The drag is produced with CDPInput.dispatchDragEvent, which goes through the renderer's real hit-testing, so bodypointer-events: noneunder the open menu is exercised the way an OS drag exercises it (a syntheticDragEventwould bypass it). Script:evidence.mjsin the media ref linked below.57eef3998)a992d5cd, same script)pointer-events: nonepointer-events: nonedragEntercarrying a file at the window edgepointer-events: autononedragOverthe composerdrophello.txtchip in the composerScreenshots / video
This head, during the drag and after the drop:
Main (control, same script): menu stays open, nothing attaches
Full captures and the
result.jsonfor both runs: refs/media/pr-13541 @ f156d01b.Related Issues
Fixes #13540
Pattern harvest
Rule candidate: review-prompt
Pattern: a modal Radix layer (menu, popover) is re-exported bare; any new one must go through a wrapper that applies
useCloseOnFileDrag, or a native file drag is swallowed while it is open.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)