fix(sidebar): preserve tree expansion state after dropping a table
Remove the dropped table node directly instead of refreshing the entire table list, which was causing all tree nodes to collapse.
This commit is contained in:
parent
cec7d6d7ad
commit
2af94c6fea
|
|
@ -732,7 +732,7 @@ async function confirmDropTable() {
|
|||
await connectionStore.ensureConnected(node.connectionId);
|
||||
await api.executeQuery(node.connectionId, node.database, buildDropTableSql(), node.schema);
|
||||
toast(t("contextMenu.dropTableSuccess", { name: node.label }), 3000);
|
||||
await refreshTableList(node);
|
||||
connectionStore.removeTreeNode(node.id);
|
||||
} catch (e: any) {
|
||||
toast(t("contextMenu.tableOperationFailed", { message: e?.message || String(e) }), 5000);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,6 +251,13 @@ export const useConnectionStore = defineStore("connection", () => {
|
|||
loadedTreeNodeChildrenIds.value.add(parent.id);
|
||||
}
|
||||
|
||||
function removeTreeNode(nodeId: string) {
|
||||
const parent = findParentNode(treeNodes.value, nodeId);
|
||||
if (parent?.children) {
|
||||
parent.children = parent.children.filter((c) => c.id !== nodeId);
|
||||
}
|
||||
}
|
||||
|
||||
function buildSavedSqlRootNode(connectionId: string, existingRoot?: TreeNode): TreeNode {
|
||||
const savedSqlStore = useSavedSqlStore();
|
||||
const existingById = new Map<string, TreeNode>();
|
||||
|
|
@ -1565,6 +1572,7 @@ export const useConnectionStore = defineStore("connection", () => {
|
|||
activeConnectionId,
|
||||
selectedTreeNodeId,
|
||||
treeNodes,
|
||||
removeTreeNode,
|
||||
refreshAllTree,
|
||||
refreshSavedSqlTree,
|
||||
refreshTreeNode,
|
||||
|
|
|
|||
Loading…
Reference in New Issue