mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
fix: Move HandlePlatformFileDrop to window._wails internal API (#4616)
* fix: Move HandlePlatformFileDrop to window._wails internal API Fixes #4489 ## Problem The npm package @wailsio/runtime doesn't work for drag-and-drop because Go backend calls window.wails.Window.HandlePlatformFileDrop(), but the npm package doesn't populate window.wails (by design for encapsulation). ## Root Cause PR #3295 (March 2024) intentionally removed window.wails assignment from the npm package to improve encapsulation. However, this broke platform handlers that Go backend relies on. ## Solution Move HandlePlatformFileDrop from public API (window.wails) to internal API (window._wails), following the existing pattern: - window._wails.invoke - window._wails.environment - window._wails.flags ## Changes - Register handlePlatformFileDrop in window._wails namespace - Update Go backend to call window._wails.handlePlatformFileDrop() - Use camelCase naming for consistency with other internal API methods - Rebuild bundled runtime with changes ## Benefits ✅ npm package works without window.wails pollution ✅ Maintains encapsulation of public API ✅ Platform handlers clearly separated as internal ✅ Follows existing internal API conventions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: Add changelog entry for drag-and-drop fix Updates UNRELEASED_CHANGELOG.md with the fix for #4489. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4d888a3df6
commit
6665a3a4b3
5 changed files with 11 additions and 4 deletions
|
|
@ -23,7 +23,7 @@ After processing, the content will be moved to the main changelog and this file
|
|||
|
||||
## Fixed
|
||||
<!-- Bug fixes -->
|
||||
- Fix the white window appearing on Windows when creating a hidden window by @leaanthony in [#4612](https://github.com/wailsapp/wails/pull/4612)
|
||||
- Fix drag-and-drop not working when using npm package @wailsio/runtime (#4489) by @leaanthony in #4616
|
||||
|
||||
## Deprecated
|
||||
<!-- Soon-to-be removed features -->
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -54,4 +54,10 @@ export * from "./cancellable.js";
|
|||
|
||||
// Notify backend
|
||||
window._wails.invoke = System.invoke;
|
||||
|
||||
// Register platform handlers (internal API)
|
||||
// Note: Window is the thisWindow instance (default export from window.ts)
|
||||
// Binding ensures 'this' correctly refers to the current window instance
|
||||
window._wails.handlePlatformFileDrop = Window.HandlePlatformFileDrop.bind(Window);
|
||||
|
||||
System.invoke("wails:runtime:ready");
|
||||
|
|
|
|||
|
|
@ -1498,7 +1498,7 @@ func (w *WebviewWindow) InitiateFrontendDropProcessing(filenames []string, x int
|
|||
}
|
||||
|
||||
jsCall := fmt.Sprintf(
|
||||
"window.wails.Window.HandlePlatformFileDrop(%s, %d, %d);",
|
||||
"window._wails.handlePlatformFileDrop(%s, %d, %d);",
|
||||
string(filenamesJSON),
|
||||
x,
|
||||
y,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue