Skip to content

[V3] windows: fix html #4259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: v3-alpha
Choose a base branch
from
Open

Conversation

mbaklor
Copy link

@mbaklor mbaklor commented Apr 30, 2025

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
    • 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.

Copy link
Contributor

coderabbitai bot commented Apr 30, 2025

Walkthrough

The update modifies the logic for handling drag-and-drop functionality in the Windows-specific implementation of a webview window. The call to disable external drag via chromium.AllowExternalDrag(false) is now executed only when drag-and-drop is enabled, rather than unconditionally. Error handling and the rest of the drag-and-drop setup remain unchanged. Additionally, a commented-out block related to AllowExternalDrag and message callbacks was removed. A corresponding fixed issue entry was added to the changelog documenting this correction. There are no alterations to public or exported entities.

Changes

File(s) Change Summary
v3/pkg/application/webview_window_windows.go Moved the call to chromium.AllowExternalDrag(false) inside the drag-and-drop enabled condition; removed commented-out code related to AllowExternalDrag.
docs/src/content/docs/changelog.mdx Added a fixed issue entry documenting the fix for HTML level drag-and-drop on Windows (#4259).

Suggested reviewers

  • leaanthony

Poem

A window in code, with drag-and-drop flair,
Now checks before disabling, with careful repair.
Only when enabled, the logic will run,
Ensuring the drag is properly done.
With paws on the keyboard and whiskers on high,
This rabbit says, "Code neatness—oh my!" 🐇


📜 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 03badf1 and dec6d4d.

📒 Files selected for processing (2)
  • docs/src/content/docs/changelog.mdx (1 hunks)
  • v3/pkg/application/webview_window_windows.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/src/content/docs/changelog.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • v3/pkg/application/webview_window_windows.go
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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.

Copy link

sonarqubecloud bot commented May 2, 2025

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

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.

2 participants