Fix sidebar drag-and-drop broken by FileDropOverlayView (#76)

* Fix sidebar drag-and-drop broken by FileDropOverlayView

The FileDropOverlayView (added in 9fd3cc2) sits on the window's theme
frame above the content view. Its hitTest returned self for all events,
causing AppKit to route drag sessions to the overlay instead of the
content view where SwiftUI lives. AppKit walks UP the superview chain
from the hit-tested view, never checking siblings — so SwiftUI's
.onDrop handlers for sidebar tab reordering were never reached.

Three changes fix this:

1. Smart hitTest: check NSPasteboard(name: .drag) for .fileURL and only
   return self during Finder file drags. Return nil otherwise so mouse
   events and internal drags pass through to the content view.

2. Custom UTType for sidebar drags: replace the fragile UTType.plainText
   hack with a proper com.cmux.sidebar-tab-reorder type registered in
   Info.plist. Uses visibility: .ownProcess since it's internal-only.

3. Narrow overlay registration: only register for .fileURL instead of
   .fileURL + .URL + .string. The broad .string type collided with
   text-based drag payloads.

* Add custom UTType Info.plist pitfall to CLAUDE.md
This commit is contained in:
Lawrence Chen 2026-02-18 17:20:22 -08:00 committed by GitHub
parent cf0f08f0e2
commit 6748c202f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 49 additions and 10 deletions

View file

@ -81,6 +81,16 @@
<string>public.data</string>
</array>
</dict>
<dict>
<key>UTTypeIdentifier</key>
<string>com.cmux.sidebar-tab-reorder</string>
<key>UTTypeDescription</key>
<string>cmux Sidebar Tab Reorder</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
</dict>
</array>
<key>SUFeedURL</key>
<string>https://github.com/manaflow-ai/cmux/releases/latest/download/appcast.xml</string>