-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Can not render HTML5 drag & drop #2014
Comments
Hey @LambdaMan2K , thanks for the issue! |
I think @wusyong said we need to allow disabling the file-drop feature. |
Ah, indeed. |
I'll try to fix this for the next release. Do you have an app I can use to test it @LambdaMan2K ? |
Thanks for the quick reply guys, this is great! Well I just used vue-cli
<template>
<draggable :list="list" @start="draggable = true" @end="draggable = false">
<div v-for="x in list" :key="x.id">
{{ x.title }}
</div>
</draggable>
</template>
<script>
import draggable from "vuedraggable";
export default {
components: { draggable },
data: () => {
return {
list: [
{ title: "item1", id: 1 },
{ title: "item2", id: 3 },
{ title: "item3", id: 2 },
],
};
},
};
</script> then just yarn tauri:serve XD if you need me to test it for you just tell me :) it just requires a simple html 5 drag and drop exapmle to test it |
Indeed, the problem is that you currently need to turn off file drop if you want draggable in the window. Maybe though we could resolve this with dropzones, like how we manage the draggable region in undecorated windows. What do you think @wusyong |
yes that seems kinda tricky, so the issue is that tauri support drag and drop of files from the os and back and now we need some kinda of abstraction to allow both features at the same time or at the time being just allow only one of them to be used? , btw I dont kno w how to share vue js code the right way on github :s the format is off |
@LambdaMan2K Write your Markdown this way: ```vue
<component></component>
<script></script>``` you may need to add a line break before the last three backticks. |
Thanks @Laegel |
Hello again, well you are right |
Hi @lucasfernog, can we get an example about how to use |
@IAmJulianAcosta in tauri.conf.json there's https://tauri.studio/docs/api/config#tauri.windows.fileDropEnabled in js:
in rust:
|
@FabianLars Where are those snippets supposed to go? |
I think you're mixing things up here. This issue is about dragging html elements around (think about trello for example) not for dropping files. For file dropping you need fileDropEnabled set to true (the default), the array should contain the file paths then. Keep in mind that you currently have to decide between file dropping and HTML5 drag-n-drop, they can't work at the same time (hopfully just for now). |
You're totally right. Indeed things are working as expected with fileDrop enabled and using |
Hi @FabianLars I'm just curious, what is the issue that impedes having both things working? |
@IAmJulianAcosta I'm not 100%, i basically just repeated what the tao/wry guys told me. I didn't reallyyy look into the relevant source code yet, so it's pretty vague, sry 😅 |
I am seeing this happen on macOS, too. My app was not seeing its DOM "drop" event handler called until I disabled {
"tauri": {
"windows": [
{
"fileDropEnabled": false The documentation should probably be updated since it only mentions this happening on Windows. |
I can't remember the reason we add file drop handler either. Maybe we can double-check this on wry too. If anyone is interested, please open an issue there, and maybe even better, help us investigate. |
@wusyong To get the file paths, not just the binary data. Which can be quite handy with the current IPC performance 😅 And the note about Windows-only is just wrong i think. maybe it was implemented only on windows at first? |
@FabianLars I believe all platform is blocked after investigating in tauri-apps/wry#904 |
I wasn't actually aware that Wry's file drop handler function expects a boolean - so far i only ever tried it out in tauri apps (i meant to create a plugin that can get the file paths even with the browser's default file drop handler by abusing NewWindowRequested on Windows and navigation events on Linux, but it was a bit too annoying so i stopped working on it). I'm gonna play around with it a bit today and see if i can spot any issues returning false. |
Okay, first quick check. Even if you return false, dropping files on the input field doesn't work on windows |
Alright I get what you mean. However I found there's new API for webview2 handling drag and drop. |
i think @amrbashir tried something with that api when it was still experimental but i can't find it anymore 🤔 |
It didn't work unfortunately! I am still waiting for this MicrosoftEdge/WebView2Feedback#2907 so I can give it another try. And last time I checked all platforms have the same issue. |
@amrbashir Maybe we can call the controller when receiving tauri event as a workaround. And it seems Linux and macOS can work if it returns false when I tested yesterday. |
What tauri event? |
I'm thinking the event here: tauri/core/tauri-runtime-wry/src/lib.rs Line 3255 in 46e6187
If the listener get the tauri file drop event, I'm wondering if we can get the webview instance there and call the method. |
that is the same as doing it in wry, and last time I did, it didn't behave as expected, I will give it another go today |
Describe the bug
Hey and thanks alot for the awesome work you guys do on this project!
well the thing is I have spend quite some time trying to figure out why I cant do drag and drop like using vuejs and the lib called vuedraggable or even raw html5 drag and drop. elements are not draggable inside tauri window and if I serve the dev-serve for the browser it renders as it should , in both chrome and edage? so if any of you guys can point me in the right direction would it be highly appreciated
To Reproduce
Steps to reproduce the behavior:
`
<draggable :list="list" @start="draggable = true" @EnD="draggable = false">
{{ x.title }}
<script> import draggable from "vuedraggable"; export default { components: { draggable }, data: () => { return { list: [ { title: "yolo", id: 1 }, { title: "damm", id: 3 }, { title: "hello", id: 2 }, ], }; }, }; </script>`
example is just a vue componet using vuedraggable
Expected behavior
elements are draggable :)
Platform and Versions (please complete the following information):
OS:Windows10
Node: v14.4.0
NPM:6.14.9
Yarn:
Rustc: 1.52.1
Stack Trace
None
The text was updated successfully, but these errors were encountered: