tauri
tauri copied to clipboard
[bug] v2 - Dynamically created windows are not being updated at 'getAll' method.
Description
On JS api, child windows created with new Window()
are not being returned in the getAll
of the parent window.
Details
I have a list of all the current opened windows in my application and a button "Create new Window" that opens up a new one. If I click the button I want my list to be mapped with the getAll
returned updated values (both parent and childs).
How to
- Create a new window with the js API of tauri-plugin-window:
import { Window, getAll } from '@tauri-apps/plugin-window';
// all inside an async function
const webview = new Window('window_1', {
url: '/',
resizable: true,
focus: true,
title: `Test`,
});
await webview.once('tauri://created', () => {
console.info('New window created.');
console.log(getAll()) // show parent and child windows
return webview;
});
await webview.once('tauri://error', (e: any) => {
console.info(e);
});
console.log(getAll()) // show only parent window.
If I log getAll()
inside the webview.once('tauri://created', () => {})
event, it will return me both parent and child windows. However, if I log getAll()
anywhere outside the event, it will return only the parent window.
Is there some async thing that I'm missing?
Versions
@tauri-apps/cli: 2.0.0-alpha.14
@tauri-apps/api: 2.0.0-alpha.8
@tauri-apps/plugin-clipboard-manager: 2.0.0-alpha.1
@tauri-apps/plugin-window: 2.0.0-alpha.1
Also found these two related issues that I'm still able to reproduce in 2.0.0-alpha.14
with the same context.
-
https://github.com/tauri-apps/tauri/issues/3297 All the child windows created on the Rust side is returned ok in the
getAll
method. But only the ones create in JS are not being updated. -
https://github.com/tauri-apps/tauri/issues/5571 Using the same scenario presented in the details, the list of windows returned by the
getAll
method are different when called by the child and parent windows. The parent window seems to be outdated, while the child window (created in js) is ok.
Maybe they are all related to the same problem?
I have the same issue on macOS.
Encountered this while watching Jacob's migration stream
Same problem.
Yup I am getting this on MacOS 12.7 and beta 9 of Tauri V2 - getAll() done from main window fails to discover/register the newly created windows. (I usually insert a few hundred ms delay before doing the getAll() to ensure the window has opened).