From 263a215f7ac09e83eda108dd28c87ea440cddd37 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 23 Sep 2026 08:00:08 -0700 Subject: [PATCH] Fix sidebar ordering for items with equal sort priorities (#705) --- apps/yaak-client/components/Sidebar.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/yaak-client/components/Sidebar.tsx b/apps/yaak-client/components/Sidebar.tsx index 3e600a27d..93762707c 100644 --- a/apps/yaak-client/components/Sidebar.tsx +++ b/apps/yaak-client/components/Sidebar.tsx @@ -941,10 +941,14 @@ const sidebarTreeAtom = atom< if (node.children != null) { childItems.sort((a, b) => { - if (a.sortPriority === b.sortPriority) { - return a.updatedAt > b.updatedAt ? 1 : -1; + if (a.sortPriority !== b.sortPriority) { + return a.sortPriority - b.sortPriority; } - return a.sortPriority - b.sortPriority; + // Keep equal-priority items in a stable order when they are edited. + if (a.createdAt !== b.createdAt) { + return a.createdAt > b.createdAt ? 1 : -1; + } + return a.id === b.id ? 0 : a.id > b.id ? 1 : -1; }); for (const item of childItems) {