Skip to content

fix(v3/windows): open context menus below the cursor - #6335

Open
DangTAnh wants to merge 3 commits into
wailsapp:masterfrom
DangTAnh:pr/6272-context-menu-placement
Open

DangTAnh wants to merge 3 commits into
wailsapp:masterfrom
DangTAnh:pr/6272-context-menu-placement

Conversation

@DangTAnh

@DangTAnh DangTAnh commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #6272.

Windows webview context menus call NewPopupMenu and ShowAtCursor, whose shared Win32Menu.ShowAt implementation hard-codes bottom alignment. This opens context menus above the cursor and can cover the clicked item.

Use native top-left placement for context menus. An unexported showAboveCursor flag preserves tray menus' previous bottom alignment and right-edge clamp. Keep the current upstream menu ownership, rebuilding, concurrency and cursor handling intact.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Windows

Refreshed branch, Go 1.26.10, from v3/:

  • go build ./pkg/application — pass.
  • go test ./pkg/application -run Menu -count=1 — pass.
  • go test ./pkg/application -count=1 — pass.
  • go vet ./pkg/application — the same nine upstream unsafe.Pointer warnings, with no new findings.
  • Formatting and upstream-relative diff checks pass.

Historical native verification before this refresh used examples/contextmenus at cursor (1280,406): the fixed menu bounds were (1280,406)-(1824,487), while the original bounds were (1280,324)-(1824,405). This is historical evidence; no new GUI or tray visual run was performed for this refresh. The alignment change calls the blocking native menu API; no new test harness was introduced.

The required coderabbit --plain command was attempted but the CLI is not installed; independent agent review was performed.

Test Configuration

Windows/amd64, Go 1.26.10. wails doctor was not run.

Checklist:

  • (v3 only) My PR title and description explain the user-visible change; I have left generated changelog entries to release automation and have not recreated v3/UNRELEASED_CHANGELOG.md
  • 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
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

AI-assisted contribution using OpenAI Codex (GPT-6).

Summary by CodeRabbit

  • New Features
    • Windows system tray menus now open above the cursor. Near the right edge of the screen, the menu shifts left to remain within the available display area. Other popup menus continue to open from the top-left, without the same right-edge adjustment.

@github-actions github-actions Bot added Bug Something isn't working v3 labels Oct 23, 2026
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Windows popup menus now use caller-configured alignment. Menus use top-left alignment by default. System tray menus enable bottom-edge alignment and retain a monitor-edge adjustment near the right edge.

Changes

Windows popup positioning

Layer / File(s) Summary
Menu alignment and tray configuration
v3/pkg/application/popupmenu_windows.go, v3/pkg/application/systemtray_windows.go
Win32Menu gains the showAboveCursor setting. ShowAt uses top-left alignment when it is false. When true, it bottom-aligns the menu and applies a right-edge adjustment when x > Right - 200. System tray menus set the option to true.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: leaanthony

Merge Risk: Minimal · up to fdfea

Window context menus open below the cursor while tray menus retain their prior alignment. No actionable merge-blocking risk was identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the Windows context-menu placement change. It is concise and directly related to the main change.
Description check Passed The description explains the issue, implementation, affected menu types, testing performed, environment, and checklist status. It links issue #6272 and identifies that wails doctor and new GUI tests w…
Linked Issues check Passed Issue #6272 requires Windows window context menus to place their top-left corner at the cursor and allows tray menus to remain above the cursor. Win32Menu.showAboveCursor defaults to false for `NewP…
Out of Scope Changes check Passed The whole-PR diff changes only Windows popup placement and the tray-menu configuration needed to preserve existing behavior. The changes do not add unrelated public API changes or unrelated features.
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Full details: Description check

Explanation

The description explains the issue, implementation, affected menu types, testing performed, environment, and checklist status. It links issue #6272 and identifies that wails doctor and new GUI tests were not run, but the required information is otherwise mostly complete.

Full details: Linked Issues check

Explanation

Issue #6272 requires Windows window context menus to place their top-left corner at the cursor and allows tray menus to remain above the cursor. Win32Menu.showAboveCursor defaults to false for NewPopupMenu, so ShowAt uses TPM_LEFTALIGN without TPM_BOTTOMALIGN for window context menus. systemtray_windows.go sets the flag for tray menus, which preserves bottom alignment and the existing right-edge handling. The whole-PR diff shows no change to ownership, rebuild, concurrency, or cursor handling.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the menu’s place,
Above the tray or cursor’s face.
At screen edges, it shifts aside,
With careful paws to guide the slide.
Then hops away, content and light.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between e4b8006 and fdfea1b.

Files selected for processing: 1
  • v3/pkg/application/popupmenu_windows.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@github-actions github-actions Bot added Documentation Improvements or additions to documentation Windows labels Oct 23, 2026
@RALIST

RALIST commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Thanks for picking this up, @DangTAnh. As the author of #6272, I confirm the change matches the fix proposed there: window context menus open at the cursor (no TPM_BOTTOMALIGN), and system tray menus keep opening above the cursor.

The branch now has a merge conflict with master. @leaanthony, could a maintainer review this once it is rebased? It affects every app that uses --custom-contextmenu on Windows: a menu taller than the space above the cursor clamps to the top of the screen and covers the clicked item.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Documentation Improvements or additions to documentation v3 Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v3][Windows] Context menus open above the cursor (TPM_BOTTOMALIGN for all popup menus)

2 participants