fix(sidebar): 修复搜索筛选树分组折叠在 scope-only 过滤下空操作

* 🐛 fix(sidebar): 修复搜索筛选树的分组折叠与重复点击切换

- 在保留搜索子树时应用临时折叠状态,避免空分组重新展开
- 仅在搜索筛选期间记录节点折叠操作
- 允许分组标签双击后的连续点击正常切换展开状态
- 补充侧边栏搜索及节点点击行为测试

* fix(sidebar): collapseAllTreeNodes 按 scope-only 过滤填充 searchCollapsedIds

---------

Co-authored-by: t8y2 <t8y2@users.noreply.github.com>
Co-authored-by: skyler <1156263951@qq.com>
This commit is contained in:
authored and GitHub committed 2026-08-06 00:55:24 +08:00
1 parent b58c221e16
commit fa6540b739
7 files changed
+66 -8

No files matched your search

@@ -223,7 +223,6 @@ function collectExpandedObjectSearchTargets(node: TreeNode, tasks: Promise<void>
}
}
const isSearching = computed(() => !!deferredSearchQuery.value);
const sidebarFilterGuards = computed(() => resolveSidebarFilterGuards(showConnectedConnectionsOnly.value, searchQuery.value, hasSearchScopeFilter.value));
// Connected-only filtering changes only root visibility, so descendant-local
// features stay available while operations requiring the full root list pause.
@@ -1178,7 +1177,7 @@ function findSchemaNode(nodes: TreeNode[], connId: string, database: string, sch
}
function onSearchToggle(node: TreeNode) {
if (!isSearching.value || !node.children) return;
if (!isTreeSearchFiltering.value || !node.children) return;
const next = new Set(searchCollapsedIds.value);
if (node.isExpanded) next.add(node.id);
else next.delete(node.id);
@@ -1441,7 +1440,9 @@ watch(sidebarTableNameFilterOpen, (open) => {
function collapseAllTreeNodes() {
store.collapseAllTreeNodes();
if (isSearching.value) {
// 与 onSearchToggle 一致:scope-only 过滤也要填充 searchCollapsedIds,
// 否则 filteredNodes 会用空集合把所有分组重建成展开态,“全部折叠”空操作。
if (isTreeSearchFiltering.value) {
searchCollapsedIds.value = new Set(flatTreeIndex.value.expandableNodeIds);
}
}
@@ -751,7 +751,7 @@ function runRowClickAction(clickDetail: number) {
return;
}
const action = treeNodeRowAction(node.type, canExpand.value, settingsStore.editorSettings.sidebarActivation);
if (!shouldRunTreeNodeRowAction(action, clickDetail)) return;
if (!shouldRunTreeNodeRowAction(action, clickDetail, isGroupLabel(node))) return;
if (action === "open-data") {
scheduleOpenData(node);
} else if (action === "open-source") {