See animated GIF below for current behavior - it's possible to drag & drop other things besides files, and we should only apply the valid drop-zone styles if the dragged content contains a file. I think this can be achievable with something like the following snippet (this is existing behavior from the LMS MVC FileDrop behavior code... copied almost verbatim).
var isFileDropValid = function( evt ) {
if ( !isUploading && evt.dataTransfer != null && evt.dataTransfer.types != null ) {
var dataTypes = evt.dataTransfer.types;
for( var i=0; i<dataTypes.length; i++ ) {
// Correcting a bizarre error where FF allows you to drag all the things
if( dataTypes[i] == 'application/x-moz-file-promise' ) {
return false;
}
if ( dataTypes[i] == 'Files' ) {
return true;
}
}
}
return false;
};
It looks like the current __onDrop method in d2l-file-uploader contains similar logic - I think its validation logic should be factored out (and possibly changed a little) into a separate method, and called from other drag events.
See animated GIF below for current behavior - it's possible to drag & drop other things besides files, and we should only apply the valid drop-zone styles if the dragged content contains a file. I think this can be achievable with something like the following snippet (this is existing behavior from the LMS MVC FileDrop behavior code... copied almost verbatim).
It looks like the current
__onDrop
method ind2l-file-uploader
contains similar logic - I think its validation logic should be factored out (and possibly changed a little) into a separate method, and called from other drag events.