diff --git a/.changes/disable-sethelpmenu.md b/.changes/disable-sethelpmenu.md new file mode 100644 index 000000000000..91b762e6735d --- /dev/null +++ b/.changes/disable-sethelpmenu.md @@ -0,0 +1,6 @@ +--- +"tauri": patch:bug +"@tauri-apps/api": patch:bug +--- + +Fix macOS help menu detection. If you have a submenu labeled "Help", macOS will automatically show the macOS help menu search box. diff --git a/crates/tauri/src/menu/menu.rs b/crates/tauri/src/menu/menu.rs index 1431b8b1b717..b36c82318a26 100644 --- a/crates/tauri/src/menu/menu.rs +++ b/crates/tauri/src/menu/menu.rs @@ -177,10 +177,11 @@ impl Menu { HELP_SUBMENU_ID, "Help", true, - &[ - #[cfg(not(target_os = "macos"))] - &PredefinedMenuItem::about(app_handle, None, Some(about_metadata))?, - ], + &[&PredefinedMenuItem::about( + app_handle, + None, + Some(about_metadata.clone()), + )?], )?; let menu = Menu::with_items( diff --git a/crates/tauri/src/menu/plugin.rs b/crates/tauri/src/menu/plugin.rs index 6db48a3d10ad..7e6863f93beb 100644 --- a/crates/tauri/src/menu/plugin.rs +++ b/crates/tauri/src/menu/plugin.rs @@ -824,12 +824,13 @@ fn set_as_help_menu_for_nsapp( webview: Webview, rid: ResourceId, ) -> crate::Result<()> { - #[cfg(target_os = "macos")] - { - let resources_table = webview.resources_table(); - let submenu = resources_table.get::>(rid)?; - submenu.set_as_help_menu_for_nsapp()?; - } + // Broken: https://github.com/tauri-apps/muda/issues/263 + // #[cfg(target_os = "macos")] + // { + // let resources_table = webview.resources_table(); + // let submenu = resources_table.get::>(rid)?; + // submenu.set_as_help_menu_for_nsapp()?; + // } let _ = rid; let _ = webview; diff --git a/crates/tauri/src/menu/submenu.rs b/crates/tauri/src/menu/submenu.rs index 0bac9d4ca99e..d75d1abb4888 100644 --- a/crates/tauri/src/menu/submenu.rs +++ b/crates/tauri/src/menu/submenu.rs @@ -404,6 +404,9 @@ impl Submenu { Ok(()) } + /// ⚠️ This is currently broken. Instead, create a menu with the label "Help" + /// so that macOS will handle this automatically + /// /// Set this submenu as the Help menu for the application on macOS. /// /// This will cause macOS to automatically add a search box to the menu. @@ -412,9 +415,16 @@ impl Submenu { /// which has a title matching the localized word "Help". #[cfg(target_os = "macos")] pub fn set_as_help_menu_for_nsapp(&self) -> crate::Result<()> { - run_item_main_thread!(self, |self_: Self| { - (*self_.0).as_ref().set_as_help_menu_for_nsapp() - })?; + // Broken: https://github.com/tauri-apps/muda/issues/263 + // + // Do not uncomment this code unless the issue is fixed! + // As of writing, `set_as_help_menu_for_nsapp` causes the help search to + // never show at all. By commenting it out, we let macOS handle it's usual + // auto-detection which is expected behaviour and works fine for most apps. + // + // run_item_main_thread!(self, |self_: Self| { + // (*self_.0).as_ref().set_as_help_menu_for_nsapp() + // })?; Ok(()) } diff --git a/examples/helloworld/main.rs b/examples/helloworld/main.rs index ee822803b95c..b3c5950e7fd9 100644 --- a/examples/helloworld/main.rs +++ b/examples/helloworld/main.rs @@ -11,6 +11,7 @@ fn greet(name: &str) -> String { fn main() { tauri::Builder::default() + .menu(tauri::menu::Menu::default) .invoke_handler(tauri::generate_handler![greet]) .run(tauri::generate_context!( "../../examples/helloworld/tauri.conf.json" diff --git a/packages/api/src/menu/submenu.ts b/packages/api/src/menu/submenu.ts index 118bb9a5d8e6..5f4345360466 100644 --- a/packages/api/src/menu/submenu.ts +++ b/packages/api/src/menu/submenu.ts @@ -277,6 +277,9 @@ export class Submenu extends MenuItemBase { } /** + * ⚠️ This is currently broken. Instead, create a menu with the label "Help" + * so that macOS will handle this automatically + * * Set this submenu as the Help menu for the application on macOS. * * This will cause macOS to automatically add a search box to the menu.