Skip to content

fix(dnd): fix drag-and-drop to folders on Windows (WebView2) - #23

Merged
thcp merged 1 commit into
mainfrom
fix/dnd-webview2
May 9, 2026
Merged

thcp merged 1 commit into
mainfrom
fix/dnd-webview2

Conversation

@thcp

@thcp thcp commented May 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes drag-and-drop of tracks to library folders not working on the Windows desktop app.

Root cause: The dragover handlers guarded e.preventDefault() behind if (!dragId) — a module-level variable set in dragstart. On WebView2 (Windows), dragId can be null when dragover fires on a different element, so e.preventDefault() was never called, causing the browser to reject the drop entirely.

Fix: Replaced the dragId guard with isTrackDragEvent(e) which checks e.dataTransfer.types.includes(TRACK_DRAG_TYPE) — the types array is always populated during dragover across all browsers, including WebView2. The custom MIME type (application/x-stemdeck-track) is only ever set by our own dragstart handler, so this guard remains exclusive to internal track drags.

drop handlers are unchanged — they still validate the track ID and existence before acting.

Test plan

  • On Windows desktop app: drag a track from the library list and drop it onto a different folder — should move correctly
  • Drag a track onto the Trash rail — should move to trash
  • Drag a track onto the main waveform panel — should load into studio
  • Confirm same behaviour works unchanged on macOS and in the browser

WebView2 (Windows) can have dragId as null when dragover fires on a
folder/trash/lanes target, preventing e.preventDefault() from being
called and blocking the drop. Check e.dataTransfer.types instead,
which is always available during dragover across all browsers.
@thcp
thcp marked this pull request as ready for review May 9, 2026 20:36
@thcp
thcp merged commit 55af86a into main May 9, 2026
1 check passed
@thcp
thcp deleted the fix/dnd-webview2 branch May 9, 2026 20:36
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.

1 participant