tauri-apps / tauri

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

[bug] Drag-and-Drop doesn't handled properly on Linux #9725

Open xingrz opened 5 months ago

xingrz commented 5 months ago

Describe the bug

As far as we know, by default, Tauri handles drag-n-drop via its own tauri://drop and related events.

While in Linux (both Ubuntu 22.04 and 24.04), once a file is dropped onto the window, an tauri://drag-cancelled is emitted instead, and the webview is unexpectedly navigated to the dropped file.

Reproduction

Link: https://github.com/xingrz/tauri-v2-drag-n-drop

  1. Run the demo
  2. Open the Web Inspector, and switch to Console tab. Enable Preserve Log image
  3. Drag and drop some file(s) onto the window
image

As its shown in the screenshot below, tauri://drag-cancelled is emitted, and the webview is navigated to the file (package.json) just dropped.

Expected behavior

image

A tauri://drop should be emitted. In the above minimal reproduction, size of the dropped file is displayed.

Full tauri info output

$ npm run tauri info

> tauri-v2-drag-n-drop@0.0.0 tauri
> tauri info

[✔] Environment
    - OS: Ubuntu 24.04 X64
    ✔ webkit2gtk-4.1: 2.44.0
    ✔ rsvg2: 2.58.0
    ✔ rustc: 1.78.0 (9b00956e5 2024-04-29)
    ✔ cargo: 1.78.0 (54d8815d0 2024-03-26)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-unknown-linux-gnu (default)
    - node: 20.13.0
    - npm: 10.5.2

[-] Packages
    - tauri [RUST]: 2.0.0-beta.18
    - tauri-build [RUST]: 2.0.0-beta.14
    - wry [RUST]: 0.39.4
    - tao [RUST]: 0.27.1
    - @tauri-apps/api [NPM]: 2.0.0-beta.11
    - @tauri-apps/cli [NPM]: 2.0.0-beta.16

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - bundler: Vite

Stack trace

No response

Additional context

No response

sidstory commented 5 months ago

not work on macos too.

xingrz commented 5 months ago

not work on macos too.

Works on my macOS 14.4.1

bicarlsen commented 2 months ago

A heads up -- in v2 the event names have changed. See https://github.com/tauri-apps/tauri/blob/b9a44105165241eacd5aa089b7b8e8c157282673/tooling/api/src/event.ts#L49