Open Jisu-Woniu opened 1 week ago
In case it is needed, I used KDE Plasma 6.1.5 (Wayland) on my machine.
Can confirm an issue is present and seems to be a Wayland problem. On Xorg drop event fires correctly.
To say more on the problem, in my case on Wayland when using the newest v2 version of a tauri there is just no way to get a filepath of a file being dragged (it is not accessible neither in drag-over, nor in drag-leave). I tried everything. On v2-beta version I can get a filepath through a drag-over event (I tested it with https://github.com/xingrz/tauri-v2-drag-n-drop), but drop event does not fire here too.
On xorg another bug appears - images of dragged files does not disappear when dropped and stays on the screen (look at the image below). Though, It might be my setup (Artix linux, GNOME 47)
In case info is needed
[✔] Environment
- OS: Artix Linux Unknown x86_64 (X64)
✔ webkit2gtk-4.1: 2.46.1
✔ rsvg2: 2.59.1
✔ rustc: 1.83.0-nightly (14f303bc1 2024-10-04)
✔ cargo: 1.83.0-nightly (80d82ca22 2024-09-27)
✔ rustup: 1.27.1 (2024-05-07)
✔ Rust toolchain: nightly-x86_64-unknown-linux-gnu (default)
- node: 22.9.0
- pnpm: 9.6.0
- yarn: 1.22.22
- npm: 10.9.0
- bun: 1.1.27
[-] Packages
- tauri 🦀: 2.0.1
- tauri-build 🦀: 2.0.1
- wry 🦀: 0.44.1
- tao 🦀: 0.30.3
- @tauri-apps/api : 2.0.2
- @tauri-apps/cli : 2.0.2
[-] Plugins
- tauri-plugin-fs 🦀: 2.0.1
- @tauri-apps/plugin-fs : 2.0.0
- tauri-plugin-shell 🦀: 2.0.1
- @tauri-apps/plugin-shell : 2.0.0
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../build
- devUrl: http://localhost:1420/
- framework: Svelte
- bundler: Vite
Having the same problem on Ubuntu 24.04. However it appears I'm running Xorg session:
$ echo $XDG_SESSION_TYPE
x11
Drag and drop events work for me, but icons get stuck like JuTonic mentioned
I think the "icons get stuck" problem should be mentioned in a separate issue. @JuTonic @metdxt
I think the "icons get stuck" problem should be mentioned in a separate issue. @JuTonic @metdxt
I agree, especially now when I know it is not a problem of my setup. Gonna open a new issue
UPD: After updating to Ubuntu 24.10, which has wayland, Tauri drop events are not working, instead default browser handlers work, which I assume is unintended. After dropping the file into the window browser just opens it. To void that one gotta make preventDefault:
<script lang="ts">
import { onMount, onDestroy } from "svelte";
import { listen, TauriEvent } from "@tauri-apps/api/event";
import type { UnlistenFn } from "@tauri-apps/api/event";
let all_paths: string[] = [];
interface DnDResult {
paths: string[];
position: { x: number; y: number };
}
let unlisten: UnlistenFn;
function preventSilent(event: DragEvent) {
event.preventDefault()
}
function preventLog(event: DragEvent) {
console.log(event);
event.preventDefault();
}
onMount(async () => {
// Both of these are needed.
window.addEventListener('dragover', preventSilent);
window.addEventListener('drop', preventLog);
unlisten = await listen(TauriEvent.DRAG_DROP, (event) => {
let { paths, position } = event.payload as DnDResult;
console.log("Files dropped:", paths);
all_paths = paths;
});
console.log("DnD handler registered");
});
onDestroy(() => {
if (unlisten) {
unlisten();
}
});
</script>
<div>
<h1>Files dropped:</h1>
<ul>
{#each all_paths as path}
<li>{path}</li>
{/each}
</ul>
</div>
However it doesn't change anything about tauri drop events not working.
I noticed that if I drag something the browser can open, e.g. SVG or JSON files, the WebView will open the file. I think it is the case, I will try to confirm that.
EDIT: Tried that, but the JSON file still opened in the WebView on my side.
Describe the bug
When dragging files to Tauri apps on Arch Linux, the Tauri app can fire
DRAG_ENTER
,DRAG_OVER
andDRAG_LEAVE
events, but notDRAG_DROP
.Reproduction
pnpm create tauri-app
Replace the
src/App.vue
file with:pnpm tauri dev
.Expected behavior
The app should produce one
tauri://drag-enter
event and onetauri://drag-drop
event for each file.But no
tauri://drag-drop
event is fired on my side.I have also checked with CrabNebula DevTools, only
tauri://drag-enter
,tauri://drag-over
andtauri://drag-leave
are fired.Full
tauri info
outputStack trace
No response
Additional context
No response