-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Description
The documentation for context menus shows that --custom-contextmenu and --default-contextmenu can be combined on the same element:
<!-- From docs/src/content/docs/features/menus/context.mdx -->
<textarea
style="--custom-contextmenu: text-menu; --default-contextmenu: show"
placeholder="Type here, then right-click...">
</textarea>The expected behavior is that the custom Go-side menu appears and the browser's default context menu is also shown (or appended).
However, the runtime implementation in v3/internal/runtime/desktop/@wailsio/runtime/src/contextmenu.ts ignores --default-contextmenu entirely when --custom-contextmenu is present:
if (customContextMenu) {
event.preventDefault(); // ← blocks native menu unconditionally
openContextMenu(customContextMenu, ...);
}
else {
processDefaultContextMenu(event, target); // ← only reached when NO custom menu
}
Since event.preventDefault() is called before checking --default-contextmenu, setting --default-contextmenu: show has no effect when --custom-contextmenu is also defined.
To Reproduce
- Create an element with both CSS variables:
<textarea style="--custom-contextmenu: my-menu; --default-contextmenu: show"></textarea>
- Register
my-menuas a context menu in Go - Right-click on the textarea
- Only the custom menu appears; the browser's native context menu (cut/copy/paste) is never shown
Expected behaviour
When --default-contextmenu: show is set alongside --custom-contextmenu, the native browser context menu should also be shown (either merged, appended, or shown sequentially). The documentation example implies this combination is supported.
Suggested fix
After opening the custom context menu, check --default-contextmenu on the same element. If it's show, do not call event.preventDefault() (or call it only after confirming the default menu should be suppressed).
Screenshots
No response
System Details
Wails v3 alpha
Platform: all (runtime-level JS issue)