From 0cc77f7a36249be0896a3a9ab7f4b875a8d8f9b2 Mon Sep 17 00:00:00 2001 From: Edouard Vanbelle Date: Mon, 20 Jul 2026 22:35:30 +0200 Subject: [PATCH] feat(ui): show a notification if user try to drop a file in another section than /files --- .../src/lib/components/ResourceList.svelte | 24 ++++++++++++++-- frontend/src/lib/components/Toaster.svelte | 28 +++++++++++++++++++ frontend/src/lib/stores/ui.svelte.ts | 24 ++++++++++++++-- frontend/static/locales/ar.json | 3 +- frontend/static/locales/de.json | 3 +- frontend/static/locales/en.json | 3 +- frontend/static/locales/es.json | 3 +- frontend/static/locales/fa.json | 3 +- frontend/static/locales/fr.json | 3 +- frontend/static/locales/hi.json | 3 +- frontend/static/locales/it.json | 3 +- frontend/static/locales/ja.json | 3 +- frontend/static/locales/ko.json | 3 +- frontend/static/locales/nl.json | 3 +- frontend/static/locales/pl.json | 3 +- frontend/static/locales/pt.json | 3 +- frontend/static/locales/ru.json | 3 +- frontend/static/locales/zh-TW.json | 3 +- frontend/static/locales/zh.json | 3 +- 19 files changed, 104 insertions(+), 20 deletions(-) diff --git a/frontend/src/lib/components/ResourceList.svelte b/frontend/src/lib/components/ResourceList.svelte index e7a003e0..3914150c 100644 --- a/frontend/src/lib/components/ResourceList.svelte +++ b/frontend/src/lib/components/ResourceList.svelte @@ -92,6 +92,8 @@ import DisplayModeControls from '$lib/components/DisplayModeControls.svelte'; import UserVignette from '$lib/components/UserVignette.svelte'; import VirtualList from '$lib/components/VirtualList.svelte'; + import { goto } from '$app/navigation'; + import { resolve } from '$app/paths'; import { t } from '$lib/i18n/index.svelte'; import { ui } from '$lib/stores/ui.svelte'; import { files as filesStore } from '$lib/stores/files.svelte'; @@ -927,7 +929,13 @@ // element accepts drops — without it, `drop` never fires and // the pointer shows the OS "no-drop" cursor. e.preventDefault(); - if (e.dataTransfer) e.dataTransfer.dropEffect = enableSystemDrop ? 'copy' : 'none'; + // `dropEffect = 'none'` would tell the browser to REJECT the + // drop before `drop` fires — the toast/notification path in + // `onSystemDrop` would never run for wrong-zone drops. Always + // accept at the pointer level; the drop handler decides + // whether to upload (`enableSystemDrop`) or fire the + // "go to Files" toast. + if (e.dataTransfer) e.dataTransfer.dropEffect = 'copy'; } function onSystemDragLeave(e: DragEvent) { if (!isSystemDrag(e)) return; @@ -949,7 +957,19 @@ 'Uploads only work in Files — open the Files section and drop there.' ), 'warning', - 6000 + 6000, + true, + { + action: { + label: t('resource_list.wrong_drop_zone_action', 'Go to Files'), + // One-click recovery from a mis-drop: land the user in + // /files so they can re-drag from the OS. We don't + // re-attach the dropped files (browsers throw away + // DataTransfer once the drop event returns), so this + // is the best we can offer without a second drag. + onClick: () => goto(resolve('/files')) + } + } ); } } diff --git a/frontend/src/lib/components/Toaster.svelte b/frontend/src/lib/components/Toaster.svelte index ed13e130..72224f33 100644 --- a/frontend/src/lib/components/Toaster.svelte +++ b/frontend/src/lib/components/Toaster.svelte @@ -12,6 +12,18 @@ {#each ui.toasts as toast (toast.id)}
{toast.message} + {#if toast.action} + + {/if}