mirror of
https://github.com/cloudreve/frontend.git
synced 2025-12-25 19:52:48 +00:00
fix(excalidraw): uploader DnD should be disabled while Excalidraw is open (fix cloudreve/cloudreve#3016)
This commit is contained in:
parent
51bbced0b3
commit
bb2f16bf5f
|
|
@ -47,14 +47,15 @@ const Uploader = () => {
|
|||
const uploadRawFiles = useAppSelector((state) => state.globalState.uploadRawFiles);
|
||||
|
||||
const displayOpt = useActionDisplayOpt([], ContextMenuTypes.empty, parent, FileManagerIndex.main);
|
||||
const exclidrawOpen = useAppSelector((state) => state.globalState.excalidrawViewer?.open);
|
||||
|
||||
useEffect(() => {
|
||||
if (!parent) {
|
||||
if (!parent || exclidrawOpen) {
|
||||
uploadEnabled.current = false;
|
||||
return;
|
||||
}
|
||||
uploadEnabled.current = displayOpt.showUpload ?? false;
|
||||
}, [parent, displayOpt.showUpload]);
|
||||
}, [parent, displayOpt.showUpload, exclidrawOpen]);
|
||||
|
||||
const taskAdded = useCallback(
|
||||
(original?: Base) => (tasks: Base[]) => {
|
||||
|
|
@ -99,10 +100,11 @@ const Uploader = () => {
|
|||
},
|
||||
onDropLeave: (_e) => {
|
||||
if (!uploadEnabled.current) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
dragCounter--;
|
||||
setDropBgOpen((value) => !value);
|
||||
return true;
|
||||
},
|
||||
onProactiveFileAdded: taskAdded(),
|
||||
onPoolEmpty: () => {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ export interface Option {
|
|||
overwrite?: boolean;
|
||||
dropZone: HTMLElement | null;
|
||||
onDropOver?: (e: DragEvent) => void;
|
||||
onDropLeave?: (e: DragEvent) => void;
|
||||
// retuen if current dopped file should be accepted.
|
||||
onDropLeave?: (e: DragEvent) => boolean;
|
||||
onToast: (type: MessageColor, msg: string) => void;
|
||||
onPoolEmpty?: () => void;
|
||||
onProactiveFileAdded?: (uploaders: Base[]) => void;
|
||||
|
|
@ -276,7 +277,10 @@ export default class UploadManager {
|
|||
}
|
||||
const containFile = e.dataTransfer && e.dataTransfer.types.includes("Files");
|
||||
if (containFile) {
|
||||
this.o.onDropLeave && this.o.onDropLeave(e);
|
||||
const shouldAccept = this.o.onDropLeave && this.o.onDropLeave(e);
|
||||
if (!shouldAccept) {
|
||||
return;
|
||||
}
|
||||
const items = await getAllFileEntries(e.dataTransfer!.items);
|
||||
const uploaders = await new Promise<Base[]>((resolve, reject) =>
|
||||
this.addFiles(items, this.currentPath as string, resolve, reject),
|
||||
|
|
|
|||
Loading…
Reference in New Issue