fix(sidebar): restore loaded pages after clearing search

This commit is contained in:
zipg authored and GitHub committed 2026-09-20 19:36:31 +08:00
1 parent 04c55ad067
commit 786fea8418
7 files changed
+152 -6

No files matched your search

@@ -434,7 +434,9 @@ function collectExpandedObjectSearchTargets(node: TreeNode, tasks: SidebarSearch
// back. Its next explicit expansion will load the ordinary first page.
node.isExpanded = false;
store.discardFilteredTreeNodeChildren(node.id);
} else {
} else if (!store.restoreFilteredObjectGroupChildren(node)) {
// Nothing was captured because the group had not been loaded before the
// search, so there is no previous list to put back.
tasks.push(() => store.loadObjectGroupChildren(node, { force: true }));
}
} else if (simpleObjectParentTypes.has(node.type)) {
@@ -21,6 +21,13 @@ describe("ConnectionTree global search loading", () => {
expect(source).toContain("store.discardFilteredTreeNodeChildren(node.id);");
});
it("restores the pre-search children of an expanded group instead of reloading page one", () => {
// Clearing a remote search must put back the pages the user had loaded
// through "load more"; only an uncaptured group falls back to a reload.
expect(source).toContain("} else if (!store.restoreFilteredObjectGroupChildren(node)) {");
expect(source).toMatch(/restoreFilteredObjectGroupChildren\(node\)\) \{[\s\S]*?tasks\.push\(\(\) => store\.loadObjectGroupChildren\(node, \{ force: true \}\)\);/);
});
it("limits concurrent metadata loads without dropping a task", async () => {
let activeTasks = 0;
let maximumActiveTasks = 0;