From 39f33e15d4d83faaef1f3ba922f5df379eda3a11 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Mon, 11 May 2026 13:21:19 +0800 Subject: [PATCH] fix(sidebar): allow search to find tables hidden behind object browser When a database has more than 15 tables, only the first 15 are shown in the tree with an "object browser" entry for the rest. The sidebar search could not find tables beyond the first 15. Store hidden table nodes on the object-browser TreeNode and search through them in filterTree when a query is active. --- src/components/sidebar/ConnectionTree.vue | 6 ++++ src/stores/connectionStore.ts | 44 ++++++++++++++++------- src/types/database.ts | 1 + 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/components/sidebar/ConnectionTree.vue b/src/components/sidebar/ConnectionTree.vue index 350f1d5399..9459a4c459 100644 --- a/src/components/sidebar/ConnectionTree.vue +++ b/src/components/sidebar/ConnectionTree.vue @@ -96,6 +96,12 @@ function filterTree(nodes: TreeNode[], q: string): TreeNode[] { const filteredNodes: TreeNode[] = []; for (const node of nodes) { + if (node.type === "object-browser" && node.hiddenChildren) { + const matches = node.hiddenChildren.filter((child) => matchSidebarLabel(normalizedLabel(child), q)); + if (matches.length > 0) filteredNodes.push(...matches); + continue; + } + const label = normalizedLabel(node); const selfMatches = !!matchSidebarLabel(label, q); const filteredChildren = node.children ? filterTree(node.children, q) : undefined; diff --git a/src/stores/connectionStore.ts b/src/stores/connectionStore.ts index 54aa804e95..1256a33a16 100644 --- a/src/stores/connectionStore.ts +++ b/src/stores/connectionStore.ts @@ -689,17 +689,25 @@ export const useConnectionStore = defineStore("connection", () => { [], defaultSchemaTables.slice(0, SIDEBAR_TABLE_NODE_LIMIT), ); - children = [ - ...previewTables, - buildObjectBrowserNode( - `${nodeId}:${SQLSERVER_DEFAULT_SCHEMA}`, - connectionId, - database, - SQLSERVER_DEFAULT_SCHEMA, - defaultSchemaTables.length, - ), - ...children.filter((child) => child.type === "schema"), - ]; + const browserNode = buildObjectBrowserNode( + `${nodeId}:${SQLSERVER_DEFAULT_SCHEMA}`, + connectionId, + database, + SQLSERVER_DEFAULT_SCHEMA, + defaultSchemaTables.length, + ); + const hiddenTables = defaultSchemaTables.slice(SIDEBAR_TABLE_NODE_LIMIT); + browserNode.hiddenChildren = hiddenTables.map((t) => ({ + id: `${nodeId}:${SQLSERVER_DEFAULT_SCHEMA}:${t.name}`, + label: t.name, + type: (t.table_type === "VIEW" ? "view" : "table") as "view" | "table", + connectionId, + database, + schema: SQLSERVER_DEFAULT_SCHEMA, + isExpanded: false, + children: [], + })); + children = [...previewTables, browserNode, ...children.filter((child) => child.type === "schema")]; } setChildren(node, children); await savePersistedTreeChildren(cacheKey, children); @@ -736,7 +744,19 @@ export const useConnectionStore = defineStore("connection", () => { children: [], })); if (tables.length > SIDEBAR_TABLE_NODE_LIMIT) { - children.push(buildObjectBrowserNode(nodeId, connectionId, database, effectiveSchema, tables.length)); + const hiddenTables = tables.slice(SIDEBAR_TABLE_NODE_LIMIT); + const browserNode = buildObjectBrowserNode(nodeId, connectionId, database, effectiveSchema, tables.length); + browserNode.hiddenChildren = hiddenTables.map((t) => ({ + id: `${nodeId}:${t.name}`, + label: t.name, + type: (t.table_type === "VIEW" ? "view" : "table") as "view" | "table", + connectionId, + database, + schema: effectiveSchema, + isExpanded: false, + children: [], + })); + children.push(browserNode); } setChildren(node, children); await savePersistedTreeChildren(cacheKey, children); diff --git a/src/types/database.ts b/src/types/database.ts index dca1fd7bc1..70de4478b7 100644 --- a/src/types/database.ts +++ b/src/types/database.ts @@ -205,6 +205,7 @@ export interface TreeNode { schema?: string; tableName?: string; objectCount?: number; + hiddenChildren?: TreeNode[]; savedSqlId?: string; savedSqlFolderId?: string; meta?: ColumnInfo | IndexInfo | ForeignKeyInfo | TriggerInfo;