mirror of
https://github.com/t8y2/dbx.git
synced 2026-11-02 08:30:35 +00:00
fix(sidebar): keep connection expansion stable
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
SIDEBAR_TREE_SCROLL_BUFFER,
|
||||
flattenTree,
|
||||
scrollTopForExpandedTreeNode,
|
||||
shouldAutoScrollExpandedTreeNode,
|
||||
shouldVirtualizeFlatTree,
|
||||
type FlatTreeNode,
|
||||
} from "@/composables/useFlatTree";
|
||||
@@ -144,6 +145,7 @@ function onSearchToggle(node: TreeNode) {
|
||||
|
||||
async function onNodeToggled(node: TreeNode, wasExpanded: boolean) {
|
||||
if (wasExpanded || !node.isExpanded) return;
|
||||
if (!shouldAutoScrollExpandedTreeNode(node.type)) return;
|
||||
|
||||
await nextTick();
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@ export function shouldVirtualizeFlatTree(count: number): boolean {
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
export function shouldAutoScrollExpandedTreeNode(type: TreeNodeType): boolean {
|
||||
return type !== "connection" && type !== "connection-group";
|
||||
}
|
||||
|
||||
export function scrollTopForExpandedTreeNode(options: {
|
||||
expandedIndex: number;
|
||||
insertedRowCount: number;
|
||||
|
||||
Reference in New Issue
Block a user