Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix(desktop): hide native Edit menu bar on Linux (#6456)
souheyl gouadria347aa2d2c56b
diff --git a/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/commands.rs b/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/commands.rsindex ed75ba244..2b82fd25b 100644--- a/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/commands.rs+++ b/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/commands.rs@@ -239,6 +239,13 @@ pub async fn load<R: Runtime>(app: AppHandle<R>, options: LoadOptions) -> Result})?;}+ #[cfg(target_os = "linux")]+ {+ if let Err(e) = window.hide_menu() {+ tracing::warn!(?e, window_label = %label, "Failed to hide menu bar");+ }+ }+let is_visible = window.is_visible().unwrap_or(false);let response = LoadResponse {success: is_visible,diff --git a/packages/hoppscotch-desktop/src-tauri/src/lib.rs b/packages/hoppscotch-desktop/src-tauri/src/lib.rsindex db89d88f3..69f0b8d93 100644--- a/packages/hoppscotch-desktop/src-tauri/src/lib.rs+++ b/packages/hoppscotch-desktop/src-tauri/src/lib.rs@@ -169,6 +169,7 @@ pub fn run() {#[cfg(target_os = "linux")]{use tauri::menu::{Menu, PredefinedMenuItem, Submenu};+ use tauri::Manager;let result = (|| -> Result<(), Box<dyn std::error::Error>> {let handle = app.handle();@@ -187,12 +188,18 @@ pub fn run() {&PredefinedMenuItem::select_all(handle, None)?,],)?;- // NOTE: This menu bar will be visible on Linux. Removing it or hiding it- // also removes the accelerator registrations and breaks clipboard shortcuts- // (webkit2gtk requires native menu items to recognise Ctrl+C/V/X etc.).+ // The menu must be registered so webkit2gtk picks up the accelerators+ // (Ctrl+C/V/X etc.), but the menu bar itself should be hidden so it+ // does not appear as a visible "Edit" strip the user cannot dismiss.// See https://github.com/tauri-apps/tauri/issues/2397let menu = Menu::with_items(handle, &[&edit_menu])?;app.set_menu(menu)?;++ for (label, window) in app.webview_windows() {+ if let Err(e) = window.hide_menu() {+ tracing::warn!(?e, window_label = %label, "Failed to hide menu bar");+ }+ }Ok(())})();