From 156144e8f5b067a2117da883ef7b437adc46473e Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Tue, 9 Jul 2024 12:37:58 -0700 Subject: [PATCH] fix (desktop): hide menu when window decorations are disabled (#2613) * fix: hide menu when window decorations are disabled * chore: clearer doc description --- packages/desktop/src/config.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/desktop/src/config.rs b/packages/desktop/src/config.rs index 820901829..2e51b81fd 100644 --- a/packages/desktop/src/config.rs +++ b/packages/desktop/src/config.rs @@ -107,6 +107,13 @@ impl Config { // gots to do a swap because the window builder only takes itself as muy self // I wish more people knew about returning &mut Self self.window = window; + if self.window.window.decorations { + if self.menu.is_none() { + self.menu = Some(default_menu_bar()); + } + } else { + self.menu = None; + } self } @@ -203,12 +210,16 @@ impl Config { /// Sets the menu the window will use. This will override the default menu bar. /// - /// > Note: A default menu bar will be enabled unless the menu is overridden or set to `None`. + /// > Note: Menu will be hidden if + /// [`with_decorations`](tao::window::WindowBuilder::with_decorations) + /// is set to false and passed into [`with_window`](Config::with_window) #[allow(unused)] pub fn with_menu(mut self, menu: impl Into>) -> Self { #[cfg(not(any(target_os = "ios", target_os = "android")))] { - self.menu = menu.into(); + if self.window.window.decorations { + self.menu = menu.into(); + } } self }