Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/disable-sethelpmenu.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 5 additions & 4 deletions crates/tauri/src/menu/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ impl<R: Runtime> Menu<R> {
HELP_SUBMENU_ID,
"Help",
true,
&[
#[cfg(not(target_os = "macos"))]
&PredefinedMenuItem::about(app_handle, None, Some(about_metadata))?,
],
&[&PredefinedMenuItem::about(
Copy link
Member

Choose a reason for hiding this comment

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

On macOS the About stuff is already in the first menu item (the one with the appname as label)

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't change anything there. I assume it's there kinda just to have something in there (looks weird otherwise)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh nvm I'm stupid, I did change it. Well yeah, I think it's best to have something there

Copy link
Member Author

Choose a reason for hiding this comment

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

Electron's default menubar has Electron's own links in there, that's an option

image

Copy link
Member

Choose a reason for hiding this comment

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

i agree that it looks weird without anything (at least as far as i can remember, didn't see check for ages)

Copy link
Member

Choose a reason for hiding this comment

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

It actually doesn't look that weird on macos 26 anymore with all that added padding. Can we perhaps still revert this part? I'm completely on board with the hotfix of the actual issue so i'd like to get it in asap but i think what we put into the help menu needs a bit more thinking since right now it's only added for visuals.

Electron's default menubar has Electron's own links in there, that's an option

Actually not a fan of that at all since it basically forces everyone to create their own menu even if they want just the default (cause they actually don't want a menu at all in the context of windows/linux)

app_handle,
None,
Some(about_metadata.clone()),
)?],
)?;

let menu = Menu::with_items(
Expand Down
13 changes: 7 additions & 6 deletions crates/tauri/src/menu/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,12 +824,13 @@ fn set_as_help_menu_for_nsapp<R: Runtime>(
webview: Webview<R>,
rid: ResourceId,
) -> crate::Result<()> {
#[cfg(target_os = "macos")]
{
let resources_table = webview.resources_table();
let submenu = resources_table.get::<Submenu<R>>(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::<Submenu<R>>(rid)?;
// submenu.set_as_help_menu_for_nsapp()?;
Copy link
Member

Choose a reason for hiding this comment

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

we're also calling it incorrectly here:

submenu.set_as_help_menu_for_nsapp()?;

// }

let _ = rid;
let _ = webview;
Expand Down
16 changes: 13 additions & 3 deletions crates/tauri/src/menu/submenu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ impl<R: Runtime> Submenu<R> {
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.
Expand All @@ -412,9 +415,16 @@ impl<R: Runtime> Submenu<R> {
/// 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(())
}

Expand Down
1 change: 1 addition & 0 deletions examples/helloworld/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/menu/submenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading