wails icon indicating copy to clipboard operation
wails copied to clipboard

[V3] windows: fix html drag and drop

Open mbaklor opened this issue 9 months ago • 2 comments

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.

  • [x] 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

  • [x] 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
    • Improved handling of drag-and-drop functionality to ensure external drag is only disabled when drag-and-drop is enabled in the app’s settings.
    • Fixed HTML level drag-and-drop functionality on Windows for better user experience.

mbaklor avatar Apr 30 '25 17:04 mbaklor

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 ea4ae708b5cf7a7c53d8c9830e4d0a5fe2c2efcc and 33fc335a62570d15195467b5f86e40939a07de01.

📒 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[bot] avatar Apr 30 '25 17:04 coderabbitai[bot]

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

sonarqubecloud[bot] avatar May 14 '25 20:05 sonarqubecloud[bot]

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

sonarqubecloud[bot] avatar Jul 02 '25 11:07 sonarqubecloud[bot]

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.

leaanthony avatar Jul 02 '25 19:07 leaanthony

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.

mbaklor avatar Jul 02 '25 23:07 mbaklor

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

sonarqubecloud[bot] avatar Aug 04 '25 09:08 sonarqubecloud[bot]