Skip to content

[v3] --default-contextmenu: show is ignored when --custom-contextmenu is set on the same element #5003

@RALIST

Description

@RALIST

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

  1. Create an element with both CSS variables:
    <textarea style="--custom-contextmenu: my-menu; --default-contextmenu: show"></textarea>
  2. Register my-menu as a context menu in Go
  3. Right-click on the textarea
  4. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions