From a22a8acf83d0473825203dc935c06fefb04221a8 Mon Sep 17 00:00:00 2001 From: ma0048 Date: Fri, 24 Jul 2026 09:12:12 +0200 Subject: [PATCH] fixed drag and drop --- public/js/helpers/DragAndDrop.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/public/js/helpers/DragAndDrop.js b/public/js/helpers/DragAndDrop.js index f98697eb2..46bc6dcf6 100644 --- a/public/js/helpers/DragAndDrop.js +++ b/public/js/helpers/DragAndDrop.js @@ -116,12 +116,12 @@ function isValidTransferData(event, allowedTypes, strict) { function getTransferData(event, strict) { const result = []; - for (const type of event.dataTransfer.types) { - if (type.substr(0, 16) != 'application/fhc-') { - if (strict) - return null; - continue; - } + const dataTypes = [...event.dataTransfer.types].filter(type => type.startsWith('application/fhc-')); + + if (!dataTypes.length) + return null; + + for (const type of dataTypes) { let base_type = type.substr(16); let collection = false; if (base_type.substr(-11) == '-collection') { @@ -266,18 +266,16 @@ function eventHasTypes(event, allowedTypes, strict) { allowedTypes = VALID_TYPES; allowedTypes = allowedTypes.map(type => 'application/fhc-' + type); - const dataTypes = [...event.dataTransfer.types]; - + const dataTypes = [...event.dataTransfer.types].filter(type => type.startsWith('application/fhc-')); // NOTE(chris): if dragging across browsers the dataTransfer object is // set to a default one without data. Since we do not support dragging // across browsers (yet) we return false which will disallow dropping. if (!dataTypes.length) return false; - + if (!strict) - return allowedTypes.some(type => [...event.dataTransfer.types].includes(type)); - - return [...event.dataTransfer.types].every(type => allowedTypes.includes(type)); + return allowedTypes.some(type => dataTypes.includes(type)); + return dataTypes.every(type => allowedTypes.includes(type)); } function bindDragEnterLeave(el, onEnter, onLeave) {