Closed ThomasSteschulat closed 3 years ago
Hi @Tewr , we have put the dataTransfer.dropEffect = "copy" in the RegisterDropEvent Method and that works for now
public RegisterDropEvents = (element: HTMLElement, additive: boolean): boolean => {
this.LogIfNull(element);
const handler = (ev: DragEvent) => {
this.PreventDefaultHandler(ev);
if (ev.target instanceof HTMLElement) {
let list = ev.dataTransfer.files;
if (additive) {
const existing = this.elementDataTransfers.get(element);
if (existing !== undefined && existing.length > 0) {
list = new FileReaderComponent.ConcatFileList(existing, list);
}
}
this.elementDataTransfers.set(element, list);
}
};
const handlerDragOver = (ev: DragEvent) => {
this.PreventDefaultHandler(ev);
**ev.dataTransfer.dropEffect = "copy";**
};
this.dragElements.set(element, handler);
element.addEventListener("drop", handler);
element.addEventListener("dragover", handlerDragOver);
return true;
}
Perhaps you can make it useable as a parameter!?
Regards Thomas
I'll have to think about a proper api here, just exposing this as a flag would be oddly specific. But the current API is indeed lacking extension points. I'm thinking some kind of simple plugin structure, I'll have to tinker a bit.
Great! I think that setting "copy" as Standard makes sense. There may be only a few situations where "move" makes sense. But first of all... its a bug in chrome :-)
And btw... great Work!
So I've tinkered a bit in this branch/PR #170. There is a small "expert" api where you can plug in your own javascript method or snippet in the event handlers. Also I wrote an extension method that adresses your specific need using that API.
You would set it up using the extension method like this (for context, see here):
await dropReference.RegisterDropEventsAsync(o => o.SetDragOverDataTransferDropEffect(DropEffect.Copy));
Let me know what you think and also if you could try it out as I don't have Outlook installed and I havent really checked for any other application that reads the dropEffect
value.
Hey Tewr! There is a bug in chrome that when someone drop a message from outllook (here Outlook 2016) on a droptarget in a browser (here blazor app with tewr.blazorfilereader) the message in outlook is deleted. It will be "moved" instead of "copied". The bug is documented here: chrome outlook drop In Comment 16 someone has a solution for this:
Solution: Indeed you have to set dataTransfer.dropEffect = 'copy' ... but you have to set it to dragenter and dragover also, not only on the drop event. Then you can drag / drop emails without them going to the deleted folder :) tada!
My question is how to achive this dataTransfer.dropEffect = 'copy' in your blazor filereader package.
Can you help me out here?
Thomas