Fix insertion order

This commit is contained in:
Oliver Walters 2026-06-19 01:26:29 +00:00
parent fb19da8db4
commit 102cbe0497
1 changed files with 5 additions and 1 deletions

View File

@ -170,7 +170,11 @@ export default function NavigationTree({
if (!sourceNodes.length) return []; if (!sourceNodes.length) return [];
for (const raw of sourceNodes) { // Sort by level so parents are always inserted before their children,
// regardless of the order the API returns items (e.g. after ancestor union in search mode).
const sorted = [...sourceNodes].sort((a, b) => a.level - b.level);
for (const raw of sorted) {
const node = { const node = {
...raw, ...raw,
children: [], children: [],