Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] WebviewWindow doesn't adhere to x,y WindowOptions #11430

Closed
someone2080 opened this issue Oct 21, 2024 · 4 comments · Fixed by tauri-apps/tao#992
Closed

[bug] WebviewWindow doesn't adhere to x,y WindowOptions #11430

someone2080 opened this issue Oct 21, 2024 · 4 comments · Fixed by tauri-apps/tao#992
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@someone2080
Copy link

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

@someone2080 someone2080 added status: needs triage This issue needs to triage, applied to new issues type: bug labels Oct 21, 2024
@amrbashir
Copy link
Member

I can't reproduce, please make a minmal repro

@someone2080
Copy link
Author

I can't reproduce, please make a minmal repro

Here's a repo

@amrbashir
Copy link
Member

opened tauri-apps/tao#992 to fix it, thanks for the repro

@someone2080
Copy link
Author

Awesome! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants