tauri-apps / plugins-workspace

All of the official Tauri plugins in one place!
https://tauri.app
Apache License 2.0
966 stars 272 forks source link

[bug] Click event is triggered twice #2051

Open serdardidan opened 3 days ago

serdardidan commented 3 days ago

Describe the bug

I followed the steps in the link below. I didn't any change the created files at all.

https://v2.tauri.app/start/create-project/

After the "npm run tauri dev" command the application worked. I clicked on the Tauri icon. Tauri link opens two web pages.

The same problem occurs in the release exe created after the "npm run tauri build -release" command.

Reproduction

Follow the steps in the link on Windows. https://v2.tauri.app/start/create-project/

Expected behavior

https://tauri.app/ should only be opened once

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22631 x86_64 (X64)
    ✔ WebView2: 130.0.2849.80
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
    ✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.13.1
    - npm: 10.5.2

[-] Packages
    - tauri 🦀: 2.1.1
    - tauri-build 🦀: 2.0.3
    - wry 🦀: 0.47.0
    - tao 🦀: 0.30.8
    - @tauri-apps/api : not installed!
    - @tauri-apps/cli : 2.1.0

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : not installed!

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../src

Stack trace

No response

Additional context

Windows 11 Home 23H2

FabianLars commented 3 days ago

hmm it doesn't do that for me. nvm it does but only on windows

are there any noteworthy messages in the devtools console?

does this happen on every template?

serdardidan commented 3 days ago

I created the project with the following options.

✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, deno, bun) ✔ Choose your package manager · npm ✔ Choose your UI template · Vanilla ✔ Choose your UI flavor · JavaScript

I see 4 lines in the network tab in Devtools.

Copy all as fetch fetch("http://ipc.localhost/plugin%3Ashell%7Copen", { "headers": { "accept": "/", "sec-fetch-mode": "cors" }, "referrerPolicy": "strict-origin-when-cross-origin", "body": null, "method": "OPTIONS", "mode": "cors", "credentials": "omit" }); ; fetch("http://ipc.localhost/plugin%3Ashell%7Copen", { "headers": { "content-type": "application/json", "sec-ch-ua": "\"Chromium\";v=\"130\", \"Microsoft Edge\";v=\"130\", \"Not?A_Brand\";v=\"99\", \"Microsoft Edge WebView2\";v=\"130\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "tauri-callback": "2441965313", "tauri-error": "3679775417", "tauri-invoke-key": "gdH/2yHa}1<Fbx7Tj@1y" }, "referrer": "http://127.0.0.1:1430/", "referrerPolicy": "strict-origin-when-cross-origin", "body": "{\"path\":\"https://tauri.app/\"}", "method": "POST", "mode": "cors", "credentials": "omit" }); ; fetch("http://ipc.localhost/plugin%3Ashell%7Copen", { "headers": { "content-type": "application/json", "sec-ch-ua": "\"Chromium\";v=\"130\", \"Microsoft Edge\";v=\"130\", \"Not?A_Brand\";v=\"99\", \"Microsoft Edge WebView2\";v=\"130\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "tauri-callback": "2549648598", "tauri-error": "2296740436", "tauri-invoke-key": "gdH/2yHa}1<Fbx7Tj@1y" }, "referrer": "http://127.0.0.1:1430/", "referrerPolicy": "strict-origin-when-cross-origin", "body": "{\"path\":\"https://tauri.app/\"}", "method": "POST", "mode": "cors", "credentials": "omit" }); ; fetch("http://ipc.localhost/plugin%3Ashell%7Copen", { "headers": { "accept": "/", "sec-fetch-mode": "cors" }, "referrerPolicy": "strict-origin-when-cross-origin", "body": null, "method": "OPTIONS", "mode": "cors", "credentials": "omit" });

LZQCN commented 2 days ago

I found if the a tag contains target="blank", then two new tabs page will be created in my browser.

<a href="https://vitejs.dev" target="_blank">Test</a>
serdardidan commented 2 days ago

I checked. There is target="_blank" in the links in index.html. When you delete target="_blank", the web page opens within the application. In this case, it doesn't seem possible to understand that it was trigger twice or once. And I prefer the web page to open in the browser.