Skip to content

fix(v2): prevent DragAndDrop from triggering OnDomReady on Linux#5214

Draft
leaanthony wants to merge 1 commit into
masterfrom
fix/3563-drag-drop-ondomready
Draft

fix(v2): prevent DragAndDrop from triggering OnDomReady on Linux#5214
leaanthony wants to merge 1 commit into
masterfrom
fix/3563-drag-drop-ondomready

Conversation

@leaanthony

Copy link
Copy Markdown
Member

Summary

Fixes #3563

Two bugs were fixed in the Linux frontend's drag-and-drop handling:

  1. OnDomReady triggered on every DnD: onDragDrop() returned FALSE, signaling GTK that the drop was not handled. This allowed WebKit to process the drop as a navigation (loading the dropped file), which reloaded the page and triggered DomReady. Fix: return TRUE to indicate the drop was consumed.

  2. DisableWebViewDrop breaks custom DnD: When both DisableWebViewDrop and EnableFileDrop were true, gtk_drag_dest_unset() was called before the custom drag handlers were connected. This removed the webview as a drag destination entirely, so the custom handlers never fired. Fix: when EnableFileDrop is true, unset WebKit's default DnD, then re-register the webview as a drag destination with only the text/uri-list target for custom handling.

Changes

  • v2/internal/frontend/desktop/linux/window.c:
    • onDragDrop(): return TRUE instead of FALSE
    • SetupWebview(): restructured DnD setup to always call gtk_drag_dest_set() when enableDragAndDrop is true
  • Added test in v2/test/3563/

Test plan

  • Build a Wails v2 app on Linux with EnableFileDrop: true
  • Drag and drop a file into the window
  • Verify OnDomReady is NOT triggered again after the drop
  • Build with EnableFileDrop: true + DisableWebViewDrop: true
  • Verify drag and drop still works and file paths are received

Two bugs were fixed:

1. onDragDrop() returned FALSE, signaling GTK that the drop was not
   handled. This allowed WebKit to process the drop as a navigation,
   reloading the page and triggering DomReady. Fix: return TRUE to
   indicate the drop was consumed.

2. When both DisableWebViewDrop and EnableFileDrop were true,
   gtk_drag_dest_unset() was called before the custom drag handlers
   were connected. This removed the webview as a drag destination,
   so the custom handlers never fired. Fix: when EnableFileDrop is
   true, unset WebKit's default DnD then re-register the webview as
   a drag destination with only the text/uri-list target for custom
   handling.

Fixes #3563
@coderabbitai

coderabbitai Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e365f1e6-95ab-4516-bb42-d4ab635b0aa8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/3563-drag-drop-ondomready

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@leaanthony

Copy link
Copy Markdown
Member Author

🤖 PR Triage Review

Accepted

Prevents DragAndDrop from triggering OnDomReady on Linux (v2). Fixes event timing issue.

Platform: Linux (v2)

Next Steps: Dispatching for Linux testing.


Reviewed by Wails PR Reviewer Bot

@leaanthony leaanthony modified the milestones: v2.5.0, v2.13.0 May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v2] Files DragAndDrop bugs

1 participant