Fix drag-drop reorder

This commit is contained in:
Gregory Schier
2023-11-19 21:43:01 -08:00
parent 1f39a36f26
commit 320670de2a

View File

@@ -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;