From 320670de2a706cfa4e06228eecc45b040085810c Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Sun, 19 Nov 2023 21:43:01 -0800 Subject: [PATCH] Fix drag-drop reorder --- src-web/components/Sidebar.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src-web/components/Sidebar.tsx b/src-web/components/Sidebar.tsx index 03869d1f..90131707 100644 --- a/src-web/components/Sidebar.tsx +++ b/src-web/components/Sidebar.tsx @@ -307,8 +307,9 @@ export function Sidebar({ className }: Props) { newChildren.splice(hoveredIndex - 1, 0, child); } - const prev = newChildren[hoveredIndex - 1]?.item; - const next = newChildren[hoveredIndex + 1]?.item; + const insertedIndex = newChildren.findIndex((c) => c.item === child.item); + const prev = newChildren[insertedIndex - 1]?.item; + const next = newChildren[insertedIndex + 1]?.item; const beforePriority = prev == null || prev.model === 'workspace' ? 0 : prev.sortPriority; const afterPriority = next == null || next.model === 'workspace' ? 0 : next.sortPriority;