wails
wails copied to clipboard
[v2 - Linux] Fix backend drag and drop on Linux
Description
This PR fixes #3686 by copying a dead PR, #3704.
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)
- [x] 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.
- [x] Windows: works
- [x] macOS: works
- [x] Linux: works
If you checked Linux, please specify the distro and version: Arch Linux latest
Test Configuration
# Wails
Version | v2.9.2
Package Manager | pacman
# System
┌───────────────────────────────────────────────────────────────────────────────────────┐
| OS | Arch Linux |
| Version | Unknown |
| ID | arch |
| Go Version | go1.23.3 |
| Platform | linux |
| Architecture | amd64 |
| CPU | 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz |
| GPU | TigerLake-LP GT2 [Iris Xe Graphics] (Intel Corporation) - Driver: i915 |
| Memory | 15GB |
└───────────────────────────────────────────────────────────────────────────────────────┘
# Dependencies
┌─────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name | Status | Version |
| *docker | docker | Installed | 1:27.3.1-1 |
| gcc | gcc | Installed | 14.2.1+r134+gab884fffe3fc-1 |
| libgtk-3 | gtk3 | Installed | 1:3.24.43-4 |
| libwebkit | webkit2gtk | Installed | 2.46.4-1 |
| npm | npm | Installed | 10.9.0-1 |
| pkg-config | pkgconf | Installed | 2.1.1-1 |
└────────────────────── * - Optional Dependency ──────────────────────┘
# Diagnosis
SUCCESS Your system is ready for Wails development!
Checklist:
- [ ] I have updated
website/src/pages/changelog.mdxwith 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
I don't fully understand this PR (hopefully you do instead) but the basic reason why it works is because it registers event listeners that call e.PreventDefault() so the default file drop behaviour is stopped.
This requires doc updates because callers need to know that backend file drop handlers should be registered in OnDomReady, not OnStartup.
Summary by CodeRabbit
-
New Features
- Enhanced drag-and-drop functionality with improved event listener management.
- Added support for file drop events, ensuring listeners are registered only once during initialization.
-
Bug Fixes
- Improved handling of drag-and-drop operations to ensure callbacks are invoked only on valid drop targets.