Skip to content

Commit

Permalink
Do not show an error message when draging and dropping text
Browse files Browse the repository at this point in the history
When the browser reports a drag of items other than files (for example,
text) and then triggers a drop event with no files no error message
should be shown to the user, as in that case there would be no highlight
of the drop zone and no indication that the drop would be valid (except
for the mouse cursor); the error message should be shown only when
the drop event with no files follows a file drag.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
  • Loading branch information
danxuliu committed Jun 8, 2018
1 parent 463d92c commit 4eafae4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,8 @@ OC.Uploader.prototype = _.extend({
//remaining time
var lastUpdate, lastSize, bufferSize, buffer, bufferIndex, bufferIndex2, bufferTotal;

var dragging = false;

// add progress handlers
fileupload.on('fileuploadadd', function(e, data) {
self.log('progress handle fileuploadadd', e, data);
Expand Down Expand Up @@ -1148,13 +1150,17 @@ OC.Uploader.prototype = _.extend({
filerow.addClass('dropping-to-dir');
filerow.find('.thumbnail').addClass('icon-filetype-folder-drag-accept');
}

dragging = true;
});

var disableDropState = function() {
$('#app-content').removeClass('file-drag');
$('.dropping-to-dir').removeClass('dropping-to-dir');
$('.dir-drop').removeClass('dir-drop');
$('.icon-filetype-folder-drag-accept').removeClass('icon-filetype-folder-drag-accept');

dragging = false;
};

fileupload.on('fileuploaddragleave fileuploaddrop', disableDropState);
Expand All @@ -1164,6 +1170,10 @@ OC.Uploader.prototype = _.extend({
// file was being dragged (and thus caused "fileuploaddragover"
// to be triggered).
fileupload.on('fileuploaddropnofiles', function() {
if (!dragging) {
return;
}

disableDropState();

OC.Notification.show(t('files', 'Uploading that item is not supported'), {type: 'error'});
Expand Down

0 comments on commit 4eafae4

Please sign in to comment.