Skip to content

[v3] File drop: hover class "file-drop-target-active" sticks after abandoned drag on Windows#5779

Open
Bare7a wants to merge 5 commits into
wailsapp:masterfrom
Bare7a:fix-dnd-for-windows
Open

[v3] File drop: hover class "file-drop-target-active" sticks after abandoned drag on Windows#5779
Bare7a wants to merge 5 commits into
wailsapp:masterfrom
Bare7a:fix-dnd-for-windows

Conversation

@Bare7a

@Bare7a Bare7a commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

With EnableFileDrop: true and a data-file-drop-target element, dragging files over the window adds the file-drop-target-active class for hover styling. On Windows, if the user drags the files back out of the window (or cancels with Esc) instead of dropping, the class is never removed - any hover styling (e.g. the full-window overlay from the File Drop docs) stays visible indefinitely.

Fixes #5780

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?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Windows
  • macOS
  • Linux

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

Test Configuration

Wails v3.0.0-alpha2.115 › Wails Doctor
                                                                                                                                                                      
# System
        
┌─────────────────────────────────────────────────────────────────────┐
| Name              | Windows 10 Pro                                  |
| Version           | 2009 (Build: 26200)                             |
| ID                | 25H2                                            |
| Branding          | Windows 11 Pro                                  |
| Platform          | windows                                         |
| Architecture      | amd64                                           |
| Go WebView2Loader | true                                            |
| WebView2 Version  | 150.0.4078.65                                   |
| CPU               | AMD Ryzen 7 5800H with Radeon Graphics          |
| GPU               | NVIDIA GeForce RTX 3060 Laptop GPU (NVIDIA)     |
| Memory            | 32GB                                            |
└─────────────────────────────────────────────────────────────────────┘
                   
# Build Environment
                   
┌──────────────────────────────────────────────────────────────────────┐
| Wails CLI      | v3.0.0-alpha2.115                                   |
| Go Version     | go1.26.1                                            |
| -buildmode     | exe                                                 |
| -compiler      | gc                                                  |
| CGO_CFLAGS     |                                                     |
| CGO_CPPFLAGS   |                                                     |
| CGO_CXXFLAGS   |                                                     |
| CGO_ENABLED    | 1                                                   |
| CGO_LDFLAGS    |                                                     |
| DefaultGODEBUG | cryptocustomrand=1,tlssecpmlkem=0,urlstrictcolons=0 |
| GOAMD64        | v1                                                  |
| GOARCH         | amd64                                               |
| GOOS           | windows                                             |
└──────────────────────────────────────────────────────────────────────┘
              
# Dependencies
              
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| *Android NDK               | Not found. Install with: sdkmanager 'ndk;26.3.11579264'                   |
| *Android SDK               | C:\Users\bare7\AppData\Local\Android\Sdk                                  |
| *Android platform-tools    | Not found. Install with: sdkmanager 'platform-tools'                      |
| *Java (Android)            | Not found. Install a JDK (e.g. brew install openjdk@21) or set JAVA_HOME. |
| MSIX Packaging Tool        | Not Installed                                                             |
| MakeAppx.exe (Windows SDK) | Not Installed                                                             |
| NSIS                       | v3.12                                                                     |
| SignTool.exe (Windows SDK) | Not Installed                                                             |
| npm                        | 11.13.0                                                                   |
| docker                     | *Docker version 29.6.1, build 8900f1d (cross-compilation ready)           |
|                                                                                                        |
└─────────────────────────────────────── * - Optional Dependency ────────────────────────────────────────┘
         
# Signing
         
┌────────────────────────────────────────┐
| macOS Signing   | Not configured       |
| Windows Signing | Not configured       |
| Linux Signing   | Not configured (GPG) |
└────────────────────────────────────────┘
                     
# Checking for issues
                     
 SUCCESS  No issues found

Checklist:

  • (v2 only) I have updated website/src/pages/changelog.mdx with details of this PR (v3 changelog entries are added automatically)
  • 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

Summary by CodeRabbit

  • Bug Fixes

    • Improved drag-and-drop hover-state cleanup on Windows, preventing stale drop-target highlighting after a drag leaves the window.
  • Chores

    • Refreshed the bundled client runtime used for drag-and-drop and other window integrations to reflect the latest implementation updates.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • v3/internal/assetserver/bundledassets/runtime.debug.js
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 72bdf4b7-61d7-491f-9459-87806fad981c

📥 Commits

Reviewing files that changed from the base of the PR and between e417e34 and 92c8d87.

📒 Files selected for processing (1)
  • v3/internal/assetserver/bundledassets/runtime.debug.js

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

Walkthrough

Windows-specific dragleave handling now resets drag state and removes the active drop-target class when relatedTarget is null. The bundled runtime reflects the updated implementation, while other platforms retain their existing behavior.

Changes

Drag-and-drop hover cleanup

Layer / File(s) Summary
Windows dragleave state reset
v3/internal/runtime/desktop/@wailsio/runtime/src/window.ts, v3/internal/assetserver/bundledassets/runtime.js
Uses IsWindows to clear drag state and hover styling for null-target dragleave events on Windows, preserves non-Windows handling, and regenerates the bundled runtime.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: Windows, Bug, Javascript

Suggested reviewers: leaanthony, invalid-email-address, mbaklor

Poem

A rabbit watched the hover glow,
Then saw the Windows drag leave go.
The class now clears away,
No stale trail can stay,
While other systems keep their flow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the Windows file-drop hover-class bug being fixed.
Description check ✅ Passed The description includes the bug summary, linked issue, change type, Windows testing, and checklist items from the template.
Linked Issues check ✅ Passed The code changes match #5780 by cleaning up null-related dragleave on Windows while preserving non-Windows behavior.
Out of Scope Changes check ✅ Passed The regenerated runtime bundle appears to be the expected build artifact for the same file-drop fix, with no clear unrelated scope creep.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@Bare7a
Bare7a marked this pull request as draft July 13, 2026 14:47

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

🧹 Nitpick comments (1)
v3/internal/runtime/desktop/@wailsio/runtime/src/window.ts (1)

784-801: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consolidate the duplicate non-Windows comment.

Lines 784-785 and 798-800 explain the same non-Windows behavior. The first comment block becomes stale once the reader sees the Windows branch below. Consider trimming the first to a brief lead-in and keeping the full explanation after the branch.

♻️ Suggested comment consolidation
-        // On Linux/WebKitGTK and macOS, dragleave fires immediately with relatedTarget=null when native
-        // drag handling is involved. Ignore these spurious events - we'll clean up on drop instead.
+        // When relatedTarget is null, the drag left the window or was cancelled.
         if (event.relatedTarget === null) {
             // On Windows the DOM listeners are the only drag tracking, and Chromium fires
             // dragleave with relatedTarget=null exactly when an external drag leaves the window or 
             // is cancelled - clean up here, otherwise an abandoned drag leaves the hover state stuck.
             if (IsWindows()) {
                 dragEnterCounter = 0;
                 if (currentDropTarget) {
                     currentDropTarget.classList.remove(DROP_TARGET_ACTIVE_CLASS);
                     currentDropTarget = null;
                 }
             }
 
-            // On Linux/WebKitGTK and macOS, dragleave fires immediately with relatedTarget=null
-            // while native drag handling is involved. Ignore these spurious events - hover state
-            // there is driven natively via handleDragEnter/handleDragOver/handleDragLeave.
+            // On Linux/WebKitGTK and macOS, native handlers drive hover state, so these
+            // spurious events are ignored - we'll clean up on drop instead.
             return;
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@v3/internal/runtime/desktop/`@wailsio/runtime/src/window.ts around lines 784
- 801, Consolidate the duplicate non-Windows explanation in the dragleave
handler: shorten the comment before the event.relatedTarget check to a brief
lead-in, and retain the full Linux/WebKitGTK and macOS rationale after the
IsWindows cleanup branch. Update only the comments around the relatedTarget
handling without changing drag behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@v3/internal/runtime/desktop/`@wailsio/runtime/src/window.ts:
- Around line 784-801: Consolidate the duplicate non-Windows explanation in the
dragleave handler: shorten the comment before the event.relatedTarget check to a
brief lead-in, and retain the full Linux/WebKitGTK and macOS rationale after the
IsWindows cleanup branch. Update only the comments around the relatedTarget
handling without changing drag behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 37f23258-fa13-4ee9-b20a-d94dac551b74

📥 Commits

Reviewing files that changed from the base of the PR and between 3440ae5 and 09bcb01.

📒 Files selected for processing (1)
  • v3/internal/runtime/desktop/@wailsio/runtime/src/window.ts

@Bare7a
Bare7a force-pushed the fix-dnd-for-windows branch from dbb6543 to 09bcb01 Compare July 13, 2026 15:35
@Bare7a Bare7a changed the title [v3] File drop: hover class "file-drop-target-active" sticks after aabandoned drag on Windows [v3] File drop: hover class "file-drop-target-active" sticks after abandoned drag on Windows Jul 13, 2026
@Bare7a
Bare7a marked this pull request as ready for review July 14, 2026 06:47
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.

File drop: hover class "file-drop-target-active" sticks after an abandoned drag on Windows

1 participant