tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
79.65k stars 2.37k forks source link

[feat] Disable opening new window on ctrl/shift-click #8811

Open franciscoBSalgueiro opened 5 months ago

franciscoBSalgueiro commented 5 months ago

Describe the problem

Clicking on a link while holding ctrl or shift in Windows will open a new window. This is the default behavior for most browsers, but on a desktop app it's not what users expect. It will also not even work on production builds, since it opens a new webview window which can't access tauri.localhost.

Describe the solution you'd like

I believe this should be disabled by default, so that holding ctrl/shift makes no difference. It should just open the link on the same window as usual.

Alternatives considered

It could also open a new Tauri controlled window, but I've ever seen this kind of behavior on any native app. If someone wanted this, they should probably handle it themselves with javascript.

Additional context

I'm moving this issue here as suggested by @FabianLars on Discord.

amrbashir commented 5 months ago

Just so we don't break 1.x version, I am gonna close this issue and instead link to this similar plugin discussion for v2 and beyond

FabianLars commented 5 months ago

As far as I understood it this is not related to the shell plugin but the native WebView behavior. Basically what I had in mind was to listen to the New window requested event and disallow the window creation if desired.

gsg-thomas commented 2 weeks ago

I was able to achieve this with an event listener on auxclick preventing default. This will cover the use of the middle click. listening on click and preventing default if event.ctrlKey is true covers the ctrl+click event.