Skip to content

[V3] windows: fix html drag and drop#4259

Merged
leaanthony merged 9 commits into
wailsapp:v3-alphafrom
mbaklor:windows-dnd-fix
Aug 4, 2025
Merged

[V3] windows: fix html drag and drop#4259
leaanthony merged 9 commits into
wailsapp:v3-alphafrom
mbaklor:windows-dnd-fix

Conversation

@mbaklor

@mbaklor mbaklor commented Apr 30, 2025

Copy link
Copy Markdown
Contributor

Description

HTML drag and drop didn't work, and it looks like that's because chromium.AllowExternalDrag(false) is being called on any and all apps. I found this issue which talks about disabling ExternalDrag for apps that want windows level file drag and drop, so I assume that's why that line is being called. For now, without further understanding windows level drag and drop I figured we can disable external drag only when the app should respect windows level drag and drop.

I will add that the example for drag and drop worked even without disabling ExternalDrag, do we might not need this at all.

Fixes # (issue)

Type of change

Please select the option that is relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

ran the two dnd examples in v3/examples

  • Windows
  • macOS
  • Linux

If you checked Linux, please specify the distro and version.

Test Configuration

# System

┌────────────────────────────────────────────────────────────────────────────────────────────┐
| Name              | Windows 10 Pro                                                         |
| Version           | 2009 (Build: 26100)                                                    |
| ID                | 24H2                                                                   |
| Branding          | Windows 11 Pro                                                         |
| Platform          | windows                                                                |
| Architecture      | amd64                                                                  |
| Go WebView2Loader | true                                                                   |
| WebView2 Version  | 135.0.3179.98                                                          |
| CPU               | 12th Gen Intel(R) Core(TM) i7-12700                                    |
| GPU 1             | Intel(R) UHD Graphics 770 (Intel Corporation) - Driver: 32.0.101.6078  |
| Memory            | 16GB                                                                   |
└────────────────────────────────────────────────────────────────────────────────────────────┘

# Build Environment

┌─────────────────────────────────────────────────────────┐
| Wails CLI    | v3.0.0-dev                               |
| Go Version   | go1.24.2                                 |
| Revision     | 2abd05f7834d3d1310a76c6c378842df74fc7f3b |
| Modified     | true                                     |
| -buildmode   | exe                                      |
| -compiler    | gc                                       |
| CGO_CFLAGS   |                                          |
| CGO_CPPFLAGS |                                          |
| CGO_CXXFLAGS |                                          |
| CGO_ENABLED  | 1                                        |
| CGO_LDFLAGS  |                                          |
| GOAMD64      | v1                                       |
| GOARCH       | amd64                                    |
| GOOS         | windows                                  |
| vcs          | git                                      |
| vcs.modified | true                                     |
| vcs.revision | 2abd05f7834d3d1310a76c6c378842df74fc7f3b |
| vcs.time     | 2025-04-28T12:27:50Z                     |
└─────────────────────────────────────────────────────────┘

# Dependencies

┌───────────────────────────┐
| npm  | 10.9.2             |
| NSIS | v3.11              |
|                           |
└─ * - Optional Dependency ─┘

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • Bug Fixes

    • Resolved an issue with HTML-level drag and drop functionality on Windows.
  • Documentation

    • Updated the changelog to reflect the drag and drop bug fix.

@coderabbitai

coderabbitai Bot commented Apr 30, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The update modifies the drag-and-drop initialization logic in the Windows webview window implementation, ensuring that external drag is only allowed if drag-and-drop is enabled. It also adds a corresponding bug fix entry to the unreleased changelog, documenting the change.

Changes

Cohort / File(s) Change Summary
Webview Drag-and-Drop Logic (Windows)
v3/pkg/application/webview_window_windows.go
Restricts the call to chromium.AllowExternalDrag(false) to only when drag-and-drop is enabled; removes obsolete commented code.
Changelog Update
v3/UNRELEASED_CHANGELOG.md
Adds a bug fix entry for Windows HTML drag-and-drop functionality, crediting the contributor and linking the PR.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested labels

Bug, size:XS

Poem

A hop and a skip through Windows code,
Drag-and-drop now lightens its load.
The changelog sings of bugs now gone,
While rabbits cheer the fix upon.
With every patch, we leap ahead—
Bugs beware, for we’re well-fed! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea4ae70 and 33fc335.

📒 Files selected for processing (1)
  • v3/UNRELEASED_CHANGELOG.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • v3/UNRELEASED_CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Run Go Tests v3 (windows-latest, 1.24)
  • GitHub Check: Run Go Tests v3 (macos-latest, 1.24)
  • GitHub Check: Run Go Tests v3 (ubuntu-latest, 1.24)
  • GitHub Check: semgrep-cloud-platform/scan
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
v3/pkg/application/webview_window_windows.go (1)

1716-1724: Consider cleaning up commented-out code.

This commented block contains similar drag-and-drop functionality to what's implemented above. Since it's not being used, it's creating unnecessary code noise.

-	// We will get round to this
-	//if chromium.HasCapability(edge.AllowExternalDrop) {
-	//	err := chromium.AllowExternalDrag(w.parent.options.EnableDragAndDrop)
-	//	if err != nil {
-	//		globalApplication.handleFatalError(err)
-	//	}
-	//	if w.parent.options.EnableDragAndDrop {
-	//		chromium.MessageWithAdditionalObjectsCallback = w.processMessageWithAdditionalObjects
-	//	}
-	//}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2abd05f and 03badf1.

📒 Files selected for processing (1)
  • v3/pkg/application/webview_window_windows.go (1 hunks)
🔇 Additional comments (1)
v3/pkg/application/webview_window_windows.go (1)

1651-1656: Good fix - this resolves HTML drag and drop functionality while preserving Windows file drag and drop support.

The change correctly moves the AllowExternalDrag(false) call inside the EnableDragAndDrop conditional block, which ensures that HTML drag and drop operations are only disabled for applications that explicitly need Windows-level file drag and drop support.

Previously, HTML drag and drop was disabled for all applications regardless of whether they needed Windows file drag and drop, which caused the issue described in the PR.

leaanthony
leaanthony previously approved these changes May 5, 2025
@github-actions github-actions Bot added Documentation Improvements or additions to documentation Windows v3-alpha labels May 14, 2025
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
E Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@mbaklor mbaklor changed the title [V3] windows: fix html [V3] windows: fix html drag and drop May 14, 2025
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 2, 2025
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2025

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
E Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@leaanthony

Copy link
Copy Markdown
Member

I'm going to create a separate PR with a DnD refactor to bring it in line with v2. After some analysis last night, it seems that the window level DnD is just adding complexity and this can be achieved by making the body tag a drop zone so we'll remove it.

@mbaklor

mbaklor commented Jul 2, 2025

Copy link
Copy Markdown
Contributor Author

I don't know if this is what you mean but there's #4318 that may or may not have to do with all this.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 4, 2025
@leaanthony leaanthony enabled auto-merge (squash) August 4, 2025 09:02
@leaanthony leaanthony disabled auto-merge August 4, 2025 09:02
@sonarqubecloud

sonarqubecloud Bot commented Aug 4, 2025

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
E Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@leaanthony leaanthony merged commit 9fe9c66 into wailsapp:v3-alpha Aug 4, 2025
59 of 60 checks passed
Grantmartin2002 pushed a commit to Grantmartin2002/wails that referenced this pull request Apr 29, 2026
* fix(windows): disable external drag only when EnableDragAndDrop is set

* update changelog for html dnd fix

* remove redundant commented out code for windows dnd

* Fix changelog

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
Co-authored-by: Atterpac <89053530+atterpac@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files. v3-alpha Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants