Skip to content

Commit ff5d76c

Browse files
fix: default WindowConfig::focus to false in Default::default (#14653)
1 parent 2d28e31 commit ff5d76c

4 files changed

Lines changed: 17 additions & 4 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
tauri: patch:bug
3+
---
4+
5+
`WindowConfig::focus` is set to `false` in `WindowConfig::default()`

crates/tauri-cli/config.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
"type": "string"
232232
},
233233
"create": {
234-
"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 ```",
234+
"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 ```",
235235
"default": true,
236236
"type": "boolean"
237237
},

crates/tauri-schema-generator/schemas/config.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
"type": "string"
232232
},
233233
"create": {
234-
"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 ```",
234+
"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 ```",
235235
"default": true,
236236
"type": "boolean"
237237
},

crates/tauri-utils/src/config.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,7 @@ pub struct WindowConfig {
16531653
/// ```rust
16541654
/// tauri::Builder::default()
16551655
/// .setup(|app| {
1656-
/// tauri::WebviewWindowBuilder::from_config(app.handle(), app.config().app.windows[0])?.build()?;
1656+
/// tauri::WebviewWindowBuilder::from_config(app.handle(), &app.config().app.windows[0])?.build()?;
16571657
/// Ok(())
16581658
/// });
16591659
/// ```
@@ -2006,7 +2006,7 @@ impl Default for WindowConfig {
20062006
closable: true,
20072007
title: default_title(),
20082008
fullscreen: false,
2009-
focus: false,
2009+
focus: true,
20102010
focusable: true,
20112011
transparent: false,
20122012
maximized: false,
@@ -4384,4 +4384,12 @@ mod test {
43844384
assert!(object_json.contains("\"cwd\":null") || !object_json.contains("cwd"));
43854385
assert!(object_json.contains("\"args\":null") || !object_json.contains("args"));
43864386
}
4387+
4388+
#[test]
4389+
fn window_config_default_same_as_deserialize() {
4390+
let config_from_deserialization: WindowConfig = serde_json::from_str("{}").unwrap();
4391+
let config_from_default: WindowConfig = WindowConfig::default();
4392+
4393+
assert_eq!(config_from_deserialization, config_from_default);
4394+
}
43874395
}

0 commit comments

Comments
 (0)