From cfa3f27dc491a6579141c22686cf865be09192e2 Mon Sep 17 00:00:00 2001 From: Romit Choudhary Date: Wed, 28 Jul 2021 15:59:53 +0200 Subject: [PATCH] Fixes #3460 - Drop files here drag area not always hidden --- app/assets/javascripts/app/lib/base/html5Upload.js | 12 +++++++++--- .../app/lib/base/jquery.contenteditable.js | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/app/lib/base/html5Upload.js b/app/assets/javascripts/app/lib/base/html5Upload.js index 2a78163b0..016dc2115 100644 --- a/app/assets/javascripts/app/lib/base/html5Upload.js +++ b/app/assets/javascripts/app/lib/base/html5Upload.js @@ -102,11 +102,16 @@ } }; onDrop = function (e) { - inCounter = 0 - onDragEnter(e); - hideDropZone(dropContainer) + e.preventDefault() + e.stopPropagation() manager.processFiles(e.dataTransfer.files) }; + onDragEnd = function (e) { + inCounter = 0 + e.preventDefault() + e.stopPropagation() + hideDropZone(dropContainer) + }; showDropZone = function(dropContainer) { $(dropContainer).trigger('html5Upload.dropZone.show') @@ -126,6 +131,7 @@ manager.on(dropContainer, 'dragleave', onDragLeave) manager.on(dropContainer, 'dragover', onDragOver) manager.on(dropContainer, 'dragenter', onDragEnter) + manager.on(dropContainer, 'dragend', onDragEnd) manager.on(dropContainer, 'drop', onDrop) } diff --git a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js index 7947049ec..940073406 100644 --- a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js +++ b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js @@ -432,6 +432,8 @@ y = e.clientY var file = dataTransfer.files[0] + if(!file) return; + // look for images if (file.type.match('image.*')) { var reader = new FileReader() @@ -610,4 +612,4 @@ return plugin.value() } -}(jQuery)); \ No newline at end of file +}(jQuery));