mirror of
https://github.com/immich-app/immich.git
synced 2026-03-22 09:00:58 +03:00
fix(web): disable drag and drop for internal items (#26897)
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
let isInLockedFolder = $derived(isLockedFolderRoute(page.route.id));
|
let isInLockedFolder = $derived(isLockedFolderRoute(page.route.id));
|
||||||
|
|
||||||
let dragStartTarget: EventTarget | null = $state(null);
|
let dragStartTarget: EventTarget | null = $state(null);
|
||||||
|
let isInternalDrag = false;
|
||||||
|
|
||||||
const onDragEnter = (e: DragEvent) => {
|
const onDragEnter = (e: DragEvent) => {
|
||||||
if (e.dataTransfer && e.dataTransfer.types.includes('Files')) {
|
if (e.dataTransfer && e.dataTransfer.types.includes('Files')) {
|
||||||
@@ -133,7 +134,19 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ondragstart = () => {
|
||||||
|
isInternalDrag = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ondragend = () => {
|
||||||
|
isInternalDrag = false;
|
||||||
|
};
|
||||||
|
|
||||||
const ondragenter = (e: DragEvent) => {
|
const ondragenter = (e: DragEvent) => {
|
||||||
|
if (isInternalDrag) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onDragEnter(e);
|
onDragEnter(e);
|
||||||
@@ -146,6 +159,10 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ondrop = async (e: DragEvent) => {
|
const ondrop = async (e: DragEvent) => {
|
||||||
|
if (isInternalDrag) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
await onDrop(e);
|
await onDrop(e);
|
||||||
@@ -159,7 +176,7 @@
|
|||||||
|
|
||||||
<svelte:window onpaste={onPaste} />
|
<svelte:window onpaste={onPaste} />
|
||||||
|
|
||||||
<svelte:body {ondragenter} {ondragleave} {ondrop} />
|
<svelte:body {ondragstart} {ondragend} {ondragenter} {ondragleave} {ondrop} />
|
||||||
|
|
||||||
{#if dragStartTarget}
|
{#if dragStartTarget}
|
||||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
|
|||||||
Reference in New Issue
Block a user