Fix desktop drag events that don't have associated files (#2358)

This commit is contained in:
Evan Almloff 2024-04-25 12:34:21 -05:00 committed by GitHub
parent c835512b04
commit 6234f60b0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 12 deletions

File diff suppressed because one or more lines are too long

View file

@ -194,12 +194,17 @@ function serializeAnimationEvent(event: AnimationEvent): SerializedEvent {
}
function serializeDragEvent(event: DragEvent): SerializedEvent {
// let files = [];
// if (event.dataTransfer && event.dataTransfer.files) {
// files = ["a", "b", "c"];
// // files = await serializeFileList(event.dataTransfer.files);
// }
// return { mouse: get_mouse_data(event), files };
let files = undefined;
// On desktop if there is file data, we insert it from wry. We just add a placeholder to let the rust side of dioxus know there's files
if (
event.dataTransfer &&
event.dataTransfer.files &&
event.dataTransfer.files.length > 0
) {
files = {
files: { placeholder: [] },
};
}
return {
mouse: {
alt_key: event.altKey,
@ -208,10 +213,6 @@ function serializeDragEvent(event: DragEvent): SerializedEvent {
shift_key: event.shiftKey,
...serializeMouseEvent(event),
},
files: {
files: {
"a": [1, 2, 3],
}
},
files,
};
}