Skip to content

AI-native design editor. Open-source Figma alternative.

fix(desktop): keep the editor menu out of the Software Update window (#1230)

Danila Poyarkovf18365f753af
diff --git a/changes/1230/fixed.md b/changes/1230/fixed.md
new file mode 100644
index 000000000..19959a38e
--- /dev/null
+++ b/changes/1230/fixed.md
@@ -0,0 +1 @@
+- On Windows and Linux, the Software Update window no longer shows the editor menu bar (#1230).
diff --git a/desktop/src/menu/mod.rs b/desktop/src/menu/mod.rs
index bcac58570..ca04e0c6f 100644
--- a/desktop/src/menu/mod.rs
+++ b/desktop/src/menu/mod.rs
@@ -5,7 +5,7 @@ use std::collections::HashMap;
use std::path::Path;
use std::sync::Mutex;
use tauri::menu::{
- CheckMenuItemBuilder, MenuBuilder, MenuItemBuilder, MenuItemKind, Submenu, SubmenuBuilder,
+ CheckMenuItemBuilder, Menu, MenuBuilder, MenuItemBuilder, MenuItemKind, Submenu, SubmenuBuilder,
};
#[cfg(any(target_os = "macos", target_os = "windows"))]
@@ -249,7 +249,7 @@ fn collect_checked<R: tauri::Runtime>(
fn current_checked<R: tauri::Runtime>(app: &tauri::AppHandle<R>) -> HashMap<String, bool> {
let mut checked = HashMap::new();
- if let Some(items) = app.menu().and_then(|menu| menu.items().ok()) {
+ if let Some(items) = editor_menu(app).and_then(|menu| menu.items().ok()) {
collect_checked(items, &mut checked);
}
checked
@@ -274,14 +274,20 @@ fn find_menu_item<R: tauri::Runtime>(
None
}
+/// The menu `install_app_menu` installed: app-wide on macOS, the main window's elsewhere.
+fn editor_menu<R: tauri::Runtime>(app: &tauri::AppHandle<R>) -> Option<Menu<R>> {
+ #[cfg(target_os = "macos")]
+ return app.menu();
+ #[cfg(not(target_os = "macos"))]
+ return tauri::Manager::get_webview_window(app, "main").and_then(|window| window.menu());
+}
+
#[tauri::command]
pub fn native_menu_checked<R: tauri::Runtime>(
app: tauri::AppHandle<R>,
id: String,
) -> Result<bool, String> {
- let menu = app
- .menu()
- .ok_or_else(|| "Application menu is unavailable".to_string())?;
+ let menu = editor_menu(&app).ok_or_else(|| "Application menu is unavailable".to_string())?;
let item = find_menu_item(menu.items().map_err(|error| error.to_string())?, &id)
.ok_or_else(|| format!("Menu item not found: {id}"))?;
match item {
@@ -296,9 +302,7 @@ pub fn set_native_menu_checked<R: tauri::Runtime>(
id: String,
checked: bool,
) -> Result<(), String> {
- let menu = app
- .menu()
- .ok_or_else(|| "Application menu is unavailable".to_string())?;
+ let menu = editor_menu(&app).ok_or_else(|| "Application menu is unavailable".to_string())?;
let item = find_menu_item(menu.items().map_err(|error| error.to_string())?, &id)
.ok_or_else(|| format!("Menu item not found: {id}"))?;
match item {
@@ -363,7 +367,15 @@ pub fn install_app_menu<R: tauri::Runtime>(
builder = builder.item(menu);
}
- app.set_menu(builder.build()?)?;
+ let menu = builder.build()?;
+ // On Windows and Linux an app-wide menu is attached to every window without its own,
+ // including the Software Update window, so it goes on the editor window alone there.
+ #[cfg(target_os = "macos")]
+ app.set_menu(menu)?;
+ #[cfg(not(target_os = "macos"))]
+ if let Some(window) = tauri::Manager::get_webview_window(app, "main") {
+ window.set_menu(menu)?;
+ }
Ok(())
}