Skip to content

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

Description

@Bare7a

Wails version family

v3

Operating System

Windows

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.

To Reproduce

  1. Minimal v3 app with EnableFileDrop: true and <body data-file-drop-target>.
  2. Add the docs' hover CSS: body.file-drop-target-active { outline: 4px dashed blue; }.
  3. Drag a file from Explorer over the window (outline appears).
  4. Drag it back out of the window and release on the desktop.

Expected behaviour

Expected: hover styling is removed when the drag leaves the window.
Actual: file-drop-target-active remains on <body> until a later drop occurs.

Screenshots

No response

Attempted Fixes

No response

System Details

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

Additional context

The runtime's document-level dragleave handler discards events whose
relatedTarget is null:

https://github.com/wailsapp/wails/blob/master/v3/internal/runtime/desktop/%40wailsio/runtime/src/window.ts#L783-L787

// 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.
if (event.relatedTarget === null) {
    return;
}

Suggested fix
Make the null-relatedTarget early-return platform-aware: only skip these events on macOS/Linux (where hover is driven natively via handleDragEnter/Over/Leave anyway), and on Windows treat relatedTarget === null as leaving the window - remove the active class, reset dragEnterCounter, and clear currentDropTarget.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions