Skip to content

feat: drag-and-drop files & images into WhatsApp Web (v0.4.0)#6

Merged
karem505 merged 1 commit into
masterfrom
feat/drag-drop-files
Jun 15, 2026
Merged

feat: drag-and-drop files & images into WhatsApp Web (v0.4.0)#6
karem505 merged 1 commit into
masterfrom
feat/drag-drop-files

Conversation

@karem505

Copy link
Copy Markdown
Owner

What

Adds drag-and-drop of files and images into the WhatsApp Web window. Drop a photo, video, or document straight onto a chat to attach it — previously dropping a file did nothing.

Why it didn't work

Account windows are built with Tauri v2's default OS-level drag-and-drop handler enabled. wry then swallows the native file drop (forwarding it as a tauri://drag-drop event) before WhatsApp Web's HTML5 drop zone can receive it. On WebView2 (Windows) wry additionally calls SetAllowExternalDrop(false) + registers a custom IDropTarget, fully blocking HTML5 DnD in the page.

Fix (src-tauri/src/window.rs)

  • .disable_drag_drop_handler() on the account WebviewWindowBuilder — we don't use Tauri-side drag-drop events, so this hands drops straight to web.whatsapp.com. This is the documented requirement for HTML5 DnD on Windows, and also restores it on Linux (webkit2gtk) and macOS (WKWebView).
  • .on_navigation(|url| url.scheme() != "file") — guards against a known webkit2gtk bug (tauri#9725, #12052) where a dropped file can make the webview navigate to its file:// URL and tear down the live session. WhatsApp Web never legitimately loads file:// URLs.

Verification

  • cargo build --locked ✅ (Linux; CI covers Windows + macOS)
  • cargo test --locked → 48/48 pass ✅
  • Headless Xvfb launch ✅ — account window opens at 1100×800, no crash
  • API confirmed against tauri 2.11 / wry 0.55 source (the versions in the tree)

End-to-end drop-to-attach should be confirmed manually on a logged-in session.

Releases as v0.4.0.

🤖 Generated with Claude Code

Account windows are built with Tauri's default OS-level drag-and-drop
handler enabled, so wry swallows native file drops (forwarding them as
tauri://drag-drop events) before WhatsApp Web's HTML5 drop zone can see
them — dropping a file or image did nothing. We don't use Tauri-side
drag-drop events, so disable that handler and let the webview hand drops
straight to web.whatsapp.com. On WebView2 (Windows) this is what makes
HTML5 drag-and-drop work at all.

Also guard against a webkit2gtk bug (tauri#9725, #12052) where a dropped
file can make the webview navigate to its file:// URL and tear down the
live session: cancel any file:// navigation via on_navigation. WhatsApp
Web never legitimately loads file:// URLs.

Release v0.4.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@karem505 karem505 merged commit be04817 into master Jun 15, 2026
6 checks passed
@karem505 karem505 deleted the feat/drag-drop-files branch June 15, 2026 16:30
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