ember-native-dom-helpers
ember-native-dom-helpers copied to clipboard
`selectFiles` Does Not Support "drop" Event
Ideally I could do something like:
await selectFiles('.my-selector', [
new Blob(...),
], { eventType: 'drop' });
@jherdman so that just triggers the drop event right?
I wasn't aware of uploading files via drop had a different event.
Exactly.
I have this mostly working in a PR, but it seems like changes to support this are breaking the tap
helper. I'm not sure why yet.
I wasn't aware of uploading files via drop had a different event.
Yeah, it's slightly different. https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/File_drag_and_drop details here. It looks like it may be a bit more work than simply supporting firing the "drop" event (note event.dataTransfer
).
ya. hmm. ok. i might be able to look at that later. might be best to do a whole new helper cause the api is different.
Side Note: what could you "drop" that wouldn't be a file?
If the api can be unified i'd rather have it be an option. If there is some fundamental difference that makes better to add a new helper, I'd suggest dropFiles('.selector', files)
ya.. it's just the "event.target.files" vs "event.dataTransfer.items", and then it looks like you have to use a "getAsFile" method on each individual item. The api's are so different, that you'd have to write a whole new helper for it even if you abstracted it behind the same name.
Documentation states that DataTransfer objects can't be constructed.
https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
Can we construct a drop event programmatically that holds files at all?
@LevelbossMike I'm not very aware of the nuances of drop events, but if DataTransfer
can't be created, we might be able to create something that quacks as a DataTransfer
object and assign it to the event, similarly to how we pass an array of files instead of a FileList to the change events on file inputs.