Skip to content

Make menus to be displayed on Windows OS in v3\examples\dialogs#4928

Merged
leaanthony merged 5 commits intowailsapp:v3-alphafrom
ndianabasi:fix_dialogs_example_on_windows
Feb 2, 2026
Merged

Make menus to be displayed on Windows OS in v3\examples\dialogs#4928
leaanthony merged 5 commits intowailsapp:v3-alphafrom
ndianabasi:fix_dialogs_example_on_windows

Conversation

@ndianabasi
Copy link
Copy Markdown

@ndianabasi ndianabasi commented Jan 29, 2026

Description

This PR applies platform-specific API calls to make menus to be displayed in v3/examples/dialogs.

Fixes #4927

Screenshot 2026-01-29 104007

Type of change

Please select the option that is relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Windows
  • macOS
  • Linux

If you checked Linux, please specify the distro and version.

Test Configuration

Please paste the output of wails doctor. If you are unable to run this command, please describe your environment in as much detail as possible.

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • [ x 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
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • Bug Fixes

    • Menus now display correctly on Windows in the dialogs example; menu behavior is consistent across platforms.
  • New Features

    • Application menu is applied only on macOS while standard menus (including Help) appear on all platforms.
    • File open/save dialogs now default to the user’s home directory for a more intuitive starting location.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 29, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

Menus are now attached per-platform in the dialogs example: macOS uses app.Menu.Set(menu) while non-macOS create a window and call window.SetMenu(menu). The example also sets dialog initial directories from os.UserHomeDir() with os.TempDir() fallback and the changelog records a Windows-specific fix.

Changes

Cohort / File(s) Summary
Changelog Update
v3/UNRELEASED_CHANGELOG.md
Add Fixed entry: "Make menus to be displayed on Windows OS in v3\examples\dialogs" attributed to @ndianabasi.
Dialogs example: menu & dialogs logic
v3/examples/dialogs/main.go
Create a window before attaching menus; add AppMenu only on Darwin and use window.SetMenu(menu) on other OSes; include HelpMenu; derive dialog initial directory from os.UserHomeDir() with os.TempDir() fallback; reorder run/attach flow accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as "Run example"
    participant OS as "Runtime / OS"
    participant App as "App"
    participant Window as "Window"
    participant Menu as "Menu"

    CLI->>OS: start example process
    OS->>App: initialize
    App->>Menu: build menus (File, Edit, Window, Services, Help)
    App->>Window: app.Window.New()
    alt OS is darwin
        App->>App: app.Menu.Set(menu)
    else other OS
        App->>Window: window.SetMenu(menu)
    end
    App->>Window: show / run
    Window->>User: window displayed with attached menu
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

Windows, v3-alpha, Documentation, size:S, lgtm

Poem

🐇 I hopped through code at break of dawn,

Menus now find windows — the problem's gone.
Darwin keeps its crown so neat,
Windows shows menus on every seat.
Hooray — dialogs and menus meet! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: applying platform-specific APIs to make menus display on Windows in the dialogs example.
Description check ✅ Passed The description follows the template structure with description, issue reference (Fixes #4927), type of change, testing on Windows, and completed checklist items, though some optional items remain unchecked.
Linked Issues check ✅ Passed The code changes directly address issue #4927 by implementing platform-specific menu attachment: using app.Menu.Set() on macOS and window.SetMenu() on Windows, plus handling directory initialization with fallback logic.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing menu display on Windows in the dialogs example. Updates to UNRELEASED_CHANGELOG.md and the dialog initialization logic are directly related to the stated objective.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@v3/examples/dialogs/main.go`:
- Around line 343-351: Handle the error returned by os.UserHomeDir() instead of
ignoring it: after calling os.UserHomeDir() capture the error and, inside the
saveMenu.Add(...).OnClick handler (or before calling SetDirectory), if the call
failed or returned an empty string replace userHomeDir with a safe fallback
(e.g., os.TempDir() or "."), and then pass that non-empty fallback to
SetDirectory to avoid unexpected behavior; reference userHomeDir,
os.UserHomeDir(), saveMenu.Add(...).OnClick and SetDirectory when making the
change.

Comment thread v3/examples/dialogs/main.go Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
v3/examples/dialogs/main.go (1)

366-378: ⚠️ Potential issue | 🔴 Critical

Window must be displayed with .Show() before app.Run().

The platform-specific menu attachment logic correctly addresses issue #4927, but the code has a critical issue: the window created on line 366 is never displayed.

While the correct Wails v3 window creation API (app.Window.New()) is used, the window must be explicitly shown before calling app.Run(). All other examples in the codebase consistently call .Show() after creating a window:

  • v3/examples/window/main.go line 120
  • v3/examples/window-call/main.go line 43
  • v3/examples/dialogs-basic/main.go line 181
  • v3/examples/panic-handling/main.go line 55

Add .Show() after line 372 (the menu setup):

window.Show()

err = app.Run()

@leaanthony
Copy link
Copy Markdown
Member

The menu situation has been bothering me for a bit. I'm going to push a better way but merging this for now. Thank you for making it 🙏

@leaanthony leaanthony merged commit 470c929 into wailsapp:v3-alpha Feb 2, 2026
6 of 8 checks passed
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Feb 2, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants