feat(windows): Add DisableMenu option to WindowsWindow - #4813
Conversation
Fixed GitHub Issue wailsapp#4273 - Added the missing `DisableMenu` property to the `WindowsWindow` struct in Wails v3. ### Changes Made: 1. **`webview_window_options.go:284-286`** - Added `DisableMenu bool` property to the `WindowsWindow` struct with documentation: ```go // DisableMenu will disable the menu for the window. // Default: false DisableMenu bool ``` 2. **`webview_window_windows.go:87-89`** - Updated `setMenu()` to respect `DisableMenu` by returning early if disabled 3. **`webview_window_windows.go:362`** - Updated window creation to not process menu when `DisableMenu` is true: ```go if !options.Frameless && !options.Windows.DisableMenu { ``` 4. **`webview_window_windows.go:2342-2344`** - Updated `toggleMenuBar()` to respect `DisableMenu` 5. **`webview_window_windows.go:2457-2459`** - Updated `showMenuBar()` to respect `DisableMenu` ### Usage: ```go app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ Windows: application.WindowsWindow{ DisableMenu: true, }, }) ``` This follows the same pattern as other `Disable*` properties like `DisableIcon` and `DisableFramelessWindowDecorations`.
## Summary ### Code Changes 1. **`v3/pkg/application/webview_window_options.go:284-286`** - Added `DisableMenu` property to `WindowsWindow` struct: ```go // DisableMenu will disable the menu for the window. // Default: false DisableMenu bool ``` 2. **`v3/pkg/application/webview_window_windows.go:87-89`** - Updated `setMenu()` to return early if `DisableMenu` is true 3. **`v3/pkg/application/webview_window_windows.go:362`** - Updated window creation to skip menu processing when `DisableMenu` is true 4. **`v3/pkg/application/webview_window_windows.go:2342-2344`** - Updated `toggleMenuBar()` to respect `DisableMenu` 5. **`v3/pkg/application/webview_window_windows.go:2457-2459`** - Updated `showMenuBar()` to respect `DisableMenu` ### Documentation Changes 1. **`v3/UNRELEASED_CHANGELOG.md`** - Added entry: ``` - Add `DisableMenu` option to `WindowsWindow` to disable the menu bar on Windows (wailsapp#4273) ``` 2. **`docs/src/content/docs/features/windows/options.mdx`** - Updated Windows Options section to include `DisableMenu` with documentation and examples
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
WalkthroughAdds a ChangesDisableMenu Windows Option
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
v3/pkg/application/webview_window_windows.go (1)
2465-2469: Consider adding a DisableMenu guard for consistency.While the current implementation is functionally correct (since
w.menuwould benilwhenDisableMenuis true), adding an explicit early-return guard like the other menu functions (setMenu,toggleMenuBar,showMenuBar) would improve consistency and code clarity.func (w *windowsWebviewWindow) hideMenuBar() { + if w.parent.options.Windows.DisableMenu { + return + } if w.menu != nil { w32.SetMenu(w.hwnd, 0) } }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
docs/src/content/docs/features/windows/options.mdx(3 hunks)v3/UNRELEASED_CHANGELOG.md(1 hunks)v3/pkg/application/webview_window_options.go(1 hunks)v3/pkg/application/webview_window_windows.go(4 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2024-09-20T23:34:29.841Z
Learnt from: nixpare
Repo: wailsapp/wails PR: 3763
File: v3/examples/keybindings/main.go:16-17
Timestamp: 2024-09-20T23:34:29.841Z
Learning: In the codebase, `application.Options.KeyBindings` uses the `application.Window` type, whereas `application.WebviewWindowOptions.KeyBindings` uses `*application.WebviewWindow`. This is intentional and acceptable.
Applied to files:
v3/pkg/application/webview_window_options.gov3/pkg/application/webview_window_windows.go
📚 Learning: 2025-01-24T22:41:18.566Z
Learnt from: leaanthony
Repo: wailsapp/wails PR: 4031
File: v3/pkg/application/menu.go:199-202
Timestamp: 2025-01-24T22:41:18.566Z
Learning: In the Wails menu system (v3/pkg/application/menu.go), shared state between menus is intentionally designed and desirable. Methods like `Append()` and `Prepend()` should maintain shared references to menu items rather than creating deep copies.
Applied to files:
v3/pkg/application/webview_window_windows.go
📚 Learning: 2025-10-17T23:16:11.570Z
Learnt from: Sammy-T
Repo: wailsapp/wails PR: 4570
File: v2/internal/frontend/desktop/linux/window_webkit6.go:97-108
Timestamp: 2025-10-17T23:16:11.570Z
Learning: For webkit_6/GTK4 builds in v2/internal/frontend/desktop/linux/window_webkit6.go, GTK widget creation should not be wrapped in invokeOnMainThread. The activation mechanism (activateWg + onActivate export) already handles thread safety, and additional wrapping would cause issues.
Applied to files:
v3/pkg/application/webview_window_windows.go
🔇 Additional comments (7)
v3/UNRELEASED_CHANGELOG.md (1)
20-20: LGTM!The changelog entry clearly documents the new feature and references the related issue.
v3/pkg/application/webview_window_options.go (1)
284-286: LGTM!The new
DisableMenufield follows the established pattern used byDisableIconandDisableFramelessWindowDecorations. The placement after theMenufield is logical, and the documentation clearly explains its purpose and default value.docs/src/content/docs/features/windows/options.mdx (1)
699-699: LGTM!The documentation is clear, comprehensive, and consistent with the existing pattern. The explanation correctly describes that the menu bar will not display even if one is configured when
DisableMenuis true. The examples demonstrate proper usage.Also applies to: 710-713, 835-835
v3/pkg/application/webview_window_windows.go (4)
87-89: LGTM!The early return guard correctly prevents menu setup when
DisableMenuis true. This ensures that even ifsetMenu()is called programmatically, it has no effect when the option is disabled.
362-369: LGTM!The condition correctly ensures that the menu is only created during window initialization when both
Framelessis false ANDDisableMenuis false. This is the primary gate that prevents menu creation when the option is disabled.
2342-2344: LGTM!The guard correctly prevents menu bar toggling when
DisableMenuis true, ensuring the test plan requirement is met.
2457-2459: LGTM!The guard correctly prevents showing the menu bar when
DisableMenuis true, ensuring the test plan requirement is met.
|
# Conflicts: # docs/src/content/docs/features/windows/options.mdx # v3/pkg/application/webview_window_options.go
taliesin-ai
left a comment
There was a problem hiding this comment.
Approving DisableMenu. De-conflicted against master's restructured options.mdx and struct; dropped the stale drag-effect fields that master has since removed (kept only DisableMenu). darwin + windows cross-builds pass.
…sableMenu option to WindowsWindow




Summary
DisableMenuproperty toWindowsWindowstruct to allow disabling the menu bar on WindowsDisableMenuistrue, the window will not display a menu bar even if one is configuredDisableIconandDisableFramelessWindowDecorationspropertiesFixes #4273
Test plan
Windows.DisableMenu: trueand verify no menu bar appearsWindows.DisableMenu: false(or omitted) and verify menu bar works normallySetMenu()at runtime withDisableMenu: trueand verify it has no effecttoggleMenuBar()andshowMenuBar()withDisableMenu: trueand verify they have no effect🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
DisableMenu) to hide the window menu bar, even when a menu is configured.Documentation
DisableMenuand its default.Bug Fixes
DisableMenuwhen enabled.