From 0e09d1f9f1c9bd4ba5cdf45a2a8fe1fb96b56d7a Mon Sep 17 00:00:00 2001 From: Yuri Karamian Date: Thu, 11 Jun 2026 22:07:41 +0200 Subject: [PATCH] Notebooks: fix drag-to-reorder and drag-out-to-root by deciding the drop action from the drop coordinates instead of cleared dragover state (#97) --- src/lib/components/Sidebar.svelte | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/components/Sidebar.svelte b/src/lib/components/Sidebar.svelte index 84d6cf4..e72df07 100644 --- a/src/lib/components/Sidebar.svelte +++ b/src/lib/components/Sidebar.svelte @@ -814,8 +814,14 @@ ondragleave={() => { if (dropTargetPath === nb.path) { dropTargetPath = null; dropPosition = null; } }} ondrop={(e) => { e.preventDefault(); - const pos = dropPosition; if (draggedNotebookPath) { + // Recompute the drop position from the drop coordinates, not the dragover-set + // state: dragleave over the row's child nodes (chevron/icon/label) clears + // dropPosition before drop (esp. Windows WebView2), which mis-routed every drop + // to "nest" and broke reorder + un-nest. (issue #97) + const rect = (e.currentTarget as HTMLElement).getBoundingClientRect(); + const relY = (e.clientY - rect.top) / rect.height; + const pos = relY < 0.3 ? 'above' : relY > 0.7 ? 'below' : 'into'; if (pos === 'above' || pos === 'below') { handleNotebookReorder(draggedNotebookPath, nb.path, pos); } else {