-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Describe the bug
Can't immediately access to the created window by WebviewWindow.getByLabel in event listener (tauri://window-created).
Reproduction
- Add a
tauri://window-createdevent listener on the current application window:void listen('tauri://window-created', (event: Event<{label: string}>) => { const createdWindow = WebviewWindow.getByLabel(event.payload.label) console.log(createdWindow) if (createdWindow !== null) { onCreateWindow(createdWindow) } })
- Open DevTools Console in the current application window by
Ctrl+Shift+I - Create new window (in my case by JS API)
- DevTools Console in the current application window output
null
Expected behavior
- DevTools Console in the current application window output WebviewWindow object
Platform and versions
❯ yarn tauri info
Environment
› OS: Arch Linux Unknown X64
› Node.js: 18.8.0
› npm: 8.18.0
› pnpm: Not installed!
› yarn: 3.2.2
› rustup: 1.24.3
› rustc: 1.59.0
› cargo: 1.59.0
› Rust toolchain: stable-x86_64-unknown-linux-gnu
Packages
WARNING: no lock files found, defaulting to npm
› @tauri-apps/cli [NPM]: 1.0.5
› @tauri-apps/api [NPM]: 1.0.2
› tauri [RUST]: 1.0.5,
› tauri-build [RUST]: 1.0.4,
› tao [RUST]: 0.12.2,
› wry [RUST]: 0.19.0,
App
› build-type: bundle
› CSP: unset
› distDir: ../dist
› devPath: http://localhost:1420/
› framework: Vue.js
App directory structure
├─ src
├─ src-tauri
├─ .vscode
├─ public
├─ node_modules
├─ dist
├─ settings
└─ about
Stack trace
No response
Additional context
Current workaround:
void listen('tauri://window-created', (event: Event<{label: string}>) => {
// Can't immediately access to the created window by `WebviewWindow.getByLabel`
setTimeout(() => {
const createdWindow = WebviewWindow.getByLabel(event.payload.label)
if (createdWindow !== null) {
onCreateWindow(createdWindow)
}
}, 100)
})