Only activate overlay when dragging files [SCI-6997] (#4272)

This commit is contained in:
artoscinote 2022-07-20 13:39:04 +02:00 committed by GitHub
parent 088c4c1c94
commit d0cc3155f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -50,7 +50,7 @@
}
.sci-checkbox-container {
margin: 10px 0;
margin: 16px 0;
&.disabled {
pointer-events: none;

View file

@ -2,7 +2,7 @@
<div ref="stepContainer" class="step-container"
:id="`stepContainer${step.id}`"
@drop.prevent="dropFile"
@dragenter.prevent="!showFileModal ? dragingFile = true : null"
@dragenter.prevent="dragEnter($event)"
@dragover.prevent
:class="{ 'draging-file': dragingFile, 'showing-comments': showCommentsSidebar, 'editing-name': editingName }"
>
@ -250,6 +250,16 @@
}
},
methods: {
dragEnter(e) {
if (this.showFileModal) return;
// Detect if dragged element is a file
// https://stackoverflow.com/a/8494918
let dt = e.dataTransfer;
if (dt.types && (dt.types.indexOf ? dt.types.indexOf('Files') != -1 : dt.types.contains('Files'))) {
this.dragingFile = true;
}
},
loadAttachments() {
$.get(this.urls.attachments_url, (result) => {
this.attachments = result.data