fix: default WindowConfig::focus to false in Default::default (#14653)

This commit is contained in:
Tony
2025-12-14 16:21:44 +08:00
committed by GitHub
parent 2d28e3143e
commit ff5d76ca21
4 changed files with 17 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
tauri: patch:bug
---
`WindowConfig::focus` is set to `false` in `WindowConfig::default()`

View File

@@ -231,7 +231,7 @@
"type": "string"
},
"create": {
"description": "Whether Tauri should create this window at app startup or not.\n\n When this is set to `false` you must manually grab the config object via `app.config().app.windows`\n and create it with [`WebviewWindowBuilder::from_config`](https://docs.rs/tauri/2/tauri/webview/struct.WebviewWindowBuilder.html#method.from_config).\n\n ## Example:\n\n ```rust\n tauri::Builder::default()\n .setup(|app| {\n tauri::WebviewWindowBuilder::from_config(app.handle(), app.config().app.windows[0])?.build()?;\n Ok(())\n });\n ```",
"description": "Whether Tauri should create this window at app startup or not.\n\n When this is set to `false` you must manually grab the config object via `app.config().app.windows`\n and create it with [`WebviewWindowBuilder::from_config`](https://docs.rs/tauri/2/tauri/webview/struct.WebviewWindowBuilder.html#method.from_config).\n\n ## Example:\n\n ```rust\n tauri::Builder::default()\n .setup(|app| {\n tauri::WebviewWindowBuilder::from_config(app.handle(), &app.config().app.windows[0])?.build()?;\n Ok(())\n });\n ```",
"default": true,
"type": "boolean"
},

View File

@@ -231,7 +231,7 @@
"type": "string"
},
"create": {
"description": "Whether Tauri should create this window at app startup or not.\n\n When this is set to `false` you must manually grab the config object via `app.config().app.windows`\n and create it with [`WebviewWindowBuilder::from_config`](https://docs.rs/tauri/2/tauri/webview/struct.WebviewWindowBuilder.html#method.from_config).\n\n ## Example:\n\n ```rust\n tauri::Builder::default()\n .setup(|app| {\n tauri::WebviewWindowBuilder::from_config(app.handle(), app.config().app.windows[0])?.build()?;\n Ok(())\n });\n ```",
"description": "Whether Tauri should create this window at app startup or not.\n\n When this is set to `false` you must manually grab the config object via `app.config().app.windows`\n and create it with [`WebviewWindowBuilder::from_config`](https://docs.rs/tauri/2/tauri/webview/struct.WebviewWindowBuilder.html#method.from_config).\n\n ## Example:\n\n ```rust\n tauri::Builder::default()\n .setup(|app| {\n tauri::WebviewWindowBuilder::from_config(app.handle(), &app.config().app.windows[0])?.build()?;\n Ok(())\n });\n ```",
"default": true,
"type": "boolean"
},

View File

@@ -1653,7 +1653,7 @@ pub struct WindowConfig {
/// ```rust
/// tauri::Builder::default()
/// .setup(|app| {
/// tauri::WebviewWindowBuilder::from_config(app.handle(), app.config().app.windows[0])?.build()?;
/// tauri::WebviewWindowBuilder::from_config(app.handle(), &app.config().app.windows[0])?.build()?;
/// Ok(())
/// });
/// ```
@@ -2006,7 +2006,7 @@ impl Default for WindowConfig {
closable: true,
title: default_title(),
fullscreen: false,
focus: false,
focus: true,
focusable: true,
transparent: false,
maximized: false,
@@ -4384,4 +4384,12 @@ mod test {
assert!(object_json.contains("\"cwd\":null") || !object_json.contains("cwd"));
assert!(object_json.contains("\"args\":null") || !object_json.contains("args"));
}
#[test]
fn window_config_default_same_as_deserialize() {
let config_from_deserialization: WindowConfig = serde_json::from_str("{}").unwrap();
let config_from_default: WindowConfig = WindowConfig::default();
assert_eq!(config_from_deserialization, config_from_default);
}
}