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:
parent
c8f6f39fbb
commit
f491ea1e43
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue