Skip to content
1 change: 1 addition & 0 deletions packages/volto/news/7736.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix rearrangements of files in dnd of contents of folderish @Tishasoumya-02
15 changes: 15 additions & 0 deletions packages/volto/src/components/manage/Contents/DropZoneContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ const messages = defineMessages({
defaultMessage: 'Upload Files ({count})',
},
});
const hasFiles = (e) => {
return e.dataTransfer.types && e.dataTransfer.types.includes('Files');
};

const DropZoneContent = (props) => {
const { onOk, onCancel, pathname, children } = props;
Expand Down Expand Up @@ -82,12 +85,18 @@ const DropZoneContent = (props) => {
}, [prevrequestloading, request.loaded, onOk]);

const handleDragEnter = (e) => {
if (!hasFiles(e)) {
return;
}
e.preventDefault();
e.stopPropagation();
setIsDragOver(true);
};

const handleDragLeave = (e) => {
if (!hasFiles(e)) {
return;
}
e.preventDefault();
e.stopPropagation();
if (!e.currentTarget.contains(e.relatedTarget)) {
Expand All @@ -96,11 +105,17 @@ const DropZoneContent = (props) => {
};

const handleDragOver = (e) => {
if (!hasFiles(e)) {
return;
}
e.preventDefault();
e.stopPropagation();
};

const onDrop = async (e) => {
if (!hasFiles(e)) {
return;
}
setIsDragOver(false);
const newFiles = Array.from(e.dataTransfer.files);
const validFiles = [];
Expand Down