fix: keep saved-sql-root first after database pin/unpin (#267)

orderPinnedFirst preserves relative order but doesn't account for
saved-sql-root needing to stay first. After reordering pinned children,
move saved-sql-root back to index 0 if it was displaced.
This commit is contained in:
t8y2 2026-05-14 18:50:24 +08:00
parent c8f6f39fbb
commit f491ea1e43
1 changed files with 4 additions and 0 deletions

View File

@ -402,6 +402,10 @@ export const useConnectionStore = defineStore("connection", () => {
const parent = findParentNode(treeNodes.value, id);
if (parent?.children) {
parent.children = orderPinnedFirst(parent.children, (child) => !!child.pinned);
const sqlRootIdx = parent.children.findIndex((c) => c.type === "saved-sql-root");
if (sqlRootIdx > 0) {
parent.children.unshift(...parent.children.splice(sqlRootIdx, 1));
}
}
}
}