From 0aa18257e79b443f64056a04839e168c41b611a7 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Tue, 25 Aug 2026 10:33:13 +0800 Subject: [PATCH] fix(sidebar): restore database-first sticky headers --- .../src/components/sidebar/ConnectionTree.vue | 17 +++--- .../src/components/sidebar/TreeItem.vue | 4 +- .../app-tests/sidebarTreeAffordances.test.ts | 11 ++++ packages/app-tests/useFlatTree.test.ts | 57 ++++++++++++++++++- 4 files changed, 76 insertions(+), 13 deletions(-) diff --git a/apps/desktop/src/components/sidebar/ConnectionTree.vue b/apps/desktop/src/components/sidebar/ConnectionTree.vue index d98a91a268..7dfa0622e3 100644 --- a/apps/desktop/src/components/sidebar/ConnectionTree.vue +++ b/apps/desktop/src/components/sidebar/ConnectionTree.vue @@ -785,15 +785,14 @@ function readExpandedSidebarSchemas(): Array<{ id: string; label: string }> { return expanded; } -// The plain (non-virtualized) renderer keeps the sticky database/schema header -// via native CSS position: sticky on the container rows, mirroring the overlay -// the virtual branch renders. Only container rows stick; children scroll under -// them until the next container takes over. -function isPlainStickyContainerNode(node: TreeNode): boolean { +// The plain (non-virtualized) renderer uses the same container selection as the +// virtual sticky overlay: database containers take precedence, while schema +// containers stick only in trees without a database-level container. +function isPlainStickyContainerNode(index: number): boolean { // Mirror the virtual branch's sticky overlay: both suppress sticky headers // while a search filter is active so filtered rows don't pin at the top. if (isTreeSearchFiltering.value) return false; - return DATABASE_LEVEL_TYPES.has(node.type) || SCHEMA_LEVEL_TYPES.has(node.type); + return flatTreeIndex.value.stickyContainerIndexByIndex[index] === index; } const sidebarLayoutMonitor = createSidebarLayoutMonitor({ @@ -2506,7 +2505,7 @@ defineExpose({ focusSearch, createNewGroup, collapseAllTreeNodes, locateTabInSid /> -