-
Notifications
You must be signed in to change notification settings - Fork 828
Description
Question you want answered
How should multiple windows be handled correctly when closing the main window?
Where did you look for an answer?
I searched using the documentation search input; then checked the References (Window;WebviewWindow) section; and finally looked through Guides > Learn.
I expected a page such as Guides > Learn > Handling Multiple Windows that explains recommended patterns for managing and closing multiple windows.
Page URL
No response
Additional context
I have an application with two windows: The normal main window and a secondary, undecorated, non-closable window.
I want the secondary window to automatically close when the main window is closed. I couldn’t find any official guidance for this scenario, so I came up with the following solution inside the frontend code of the secondary window:
import { getCurrentWindow, Window } from "@tauri-apps/api/window";
const mainWindow = await Window.getByLabel("main");
await mainWindow.listen("tauri://destroyed", async () => {
const currentWindow = getCurrentWindow();
await currentWindow.destroy();
});This works, but it feels fragile. E.g. if the secondary window is missing the core:window:allow-destroy permission or if the listener registration fails or the code doesn't event reach that point.
I assume there's a more robust Rust-side approach for closing non-main windows when the main window exits.
I'd be happy to help draft such a guide, but I’m not proficient in Rust and don’t know which APIs or lifecycle hooks would be best to use.
I'm open to feedback or further questions if that helps clarify the use case or shape the guides content.
btw, I really appreciate the project and the documentation so far.
Are you willing to work on this yourself?
- I want to work on this myself
Metadata
Metadata
Assignees
Labels
Type
Projects
Status