* fix(runtime): use internal path for HandlePlatformFileDrop The Go backend was calling window.wails.Window.HandlePlatformFileDrop() for native file drops on macOS/Linux. This only worked with the bundled runtime which sets window.wails = Runtime. When using the @wailsio/runtime npm module, window.wails is an empty object because the npm module only exports via ES modules and registers the handler at window._wails.handlePlatformFileDrop. Changed the Go code to call the internal path that both runtime distributions set up: window._wails.handlePlatformFileDrop() Also added a test case that uses the npm module to verify the fix. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: add changelog entry for npm runtime DND fix Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: add built frontend dist for dnd-npm-runtime test Required for go:embed to work in CI. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update README to reflect pre-built frontend Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| frontend | ||
| main.go | ||
| README.md | ||
DND NPM Runtime Test
This test verifies that drag-and-drop functionality works correctly when using the @wailsio/runtime npm module instead of the bundled /wails/runtime.js.
Background
There was a bug where the Go backend called window.wails.Window.HandlePlatformFileDrop() for native file drops (macOS/Linux), but the npm module only registers the handler at window._wails.handlePlatformFileDrop.
The bundled runtime sets window.wails = Runtime, so the call worked. But with the npm module, window.wails is an empty object.
The Fix
Changed v3/pkg/application/webview_window.go to call the internal path that both runtimes set up:
// Before (only worked with bundled runtime):
"window.wails.Window.HandlePlatformFileDrop(%s, %d, %d);"
// After (works with both):
"window._wails.handlePlatformFileDrop(%s, %d, %d);"
Running the Test
The frontend is pre-built, so you can run directly:
go run .
Then drag files from Finder/Explorer onto the drop zone. Files should be categorized and displayed.
Rebuilding the Frontend (optional)
Only needed if you modify the frontend code:
cd frontend
npm install
npm run build
What This Tests
@wailsio/runtimenpm module initialization- Event system (
Events.On('files-dropped', ...)) - Native file drop handling on macOS/Linux via
window._wails.handlePlatformFileDrop - Drop target detection with
data-file-drop-targetattribute - Visual feedback with
.file-drop-target-activeclass