[bug] WebviewWindow doesn't adhere to x,y WindowOptions
Opened this issue · 4 comments
someone2080 commented
Describe the bug
When I try to create a new window using WebviewWindow
with x,y
options, the newly created Window appears on the Display, based on the x,y
coordinates, but then jumps to the primary Display. I have to use setPosition
method to move it to the right Display.
Sample code here:
async function createNewWindow(position: PhysicalPosition) {
const label = "sw-1"+Math.round(Math.random()*1000000)
const window_options: WindowOptions = {
title: label,
x: position.x, // broken, use setPosition()
y: position.y, // broken, use setPosition()
visible: false,
theme: "dark"
}
let webview = new WebviewWindow(label, window_options)
await webview.once('tauri://created', async function() {
console.log('tauri://created');
// position was reset to 0,0
console.log(await webview.position())
// we need to set position here again:
// await webview.setPosition(position)
await webview.show()
});
await webview.once('tauri://error', function(e) {
console.log('tauri://error', e);
});
}
Reproduction
No response
Expected behavior
A New Window should appear on the Display based on the x ,y
and stay there. This is how it worked in Tauri 1.
Full tauri info
output
[✔] Environment
- OS: Windows 10.0.22631 x86_64 (X64)
✔ WebView2: 129.0.2792.89
✔ MSVC: Visual Studio Community 2022
✔ rustc: 1.79.0 (129f3b996 2024-06-10)
✔ cargo: 1.79.0 (ffa9cf99a 2024-06-03)
✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
- node: 20.15.0
- npm: 10.7.0
- bun: 1.1.21
[-] Packages
- tauri 🦀: 2.0.5
- tauri-build 🦀: 2.0.1
- wry 🦀: 0.46.2
- tao 🦀: 0.30.3
- tauri-cli 🦀: 2.0.3
- @tauri-apps/api : 2.0.3
- @tauri-apps/cli : 2.0.3
[-] Plugins
- tauri-plugin-shell 🦀: 2.0.2
- @tauri-apps/plugin-shell : 2.0.1
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../build
- devUrl: http://localhost:1420/
- framework: Svelte
- bundler: Vite
Stack trace
No response
Additional context
No response
amrbashir commented
I can't reproduce, please make a minmal repro
someone2080 commented
I can't reproduce, please make a minmal repro
Here's a repo
amrbashir commented
opened tauri-apps/tao#992 to fix it, thanks for the repro
someone2080 commented
Awesome! Thanks!