diff --git a/crates/tauri/src/platform/windows.rs b/crates/tauri/src/platform/windows.rs index bb72dedc5..20ca541e3 100644 --- a/crates/tauri/src/platform/windows.rs +++ b/crates/tauri/src/platform/windows.rs @@ -4,10 +4,7 @@ use tauri::Window; use url::Url; pub fn show_search_bar(window: &Window) { - if let Ok(false) = window.is_visible() { - let _ = window.show(); - } - + let _ = window.show(); let _ = window.unminimize(); window::center_search_bar(window); let _ = window.set_focus(); diff --git a/crates/tauri/src/window.rs b/crates/tauri/src/window.rs index a56aa1835..4bf2f201f 100644 --- a/crates/tauri/src/window.rs +++ b/crates/tauri/src/window.rs @@ -59,8 +59,12 @@ pub fn show_search_bar(window: &Window) { #[cfg(target_os = "windows")] platform::windows::show_search_bar(window); + // Wait a little bit for the window to show being focusing on it. let window = window.clone(); - let _ = window.emit(ClientEvent::FocusWindow.as_ref(), true); + tauri::async_runtime::spawn(async move { + tokio::time::sleep(tokio::time::Duration::from_millis(256)).await; + let _ = window.emit(ClientEvent::FocusWindow.as_ref(), true); + }); } pub fn hide_search_bar(window: &Window) {