✨ Keep the swap component search when changing library (#12873)

Changing the library in the Swap component menu cleared the search
field, so checking several connected libraries for the same component
meant typing the name again for each one. Keep the term and reset only
the library id and the group path, so the new library is shown already
filtered.

Closes #12335

AI-assisted-by: claude-opus-5-5

Signed-off-by: JiMyung Lee <lee.ji.myung@gmail.com>
This commit is contained in:
JiMyung Lee 2026-11-12 20:45:36 +09:00 committed by GitHub
parent 86a8ac34cd
commit 61154e6bfe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 62 additions and 1 deletions

View File

@ -162,3 +162,62 @@ test("BUG 14214 - Updates tab refreshes after syncing a freshly linked library",
updatesPanel.getByText("There are no Shared Libraries that need update"),
).toBeVisible();
});
test("Swap component menu keeps the search when changing library", async ({
page,
}) => {
const workspace = new WasmWorkspacePage(page);
await workspace.setupEmptyFile(page);
await workspace.mockRPC(
/get\-file\?/,
"workspace/get-file-9066-swap-groups.json",
);
await workspace.mockRPC(
new RegExp(`get\\-file\\?id=${sharedFileId}`),
"workspace/get-file-9056_shared.json",
);
await workspace.mockRPC(
"get-file-libraries?file-id=*",
"workspace/get-file-libraries-9056.json",
);
await workspace.mockRPC(
`get-file-fragment?file-id=${sharedFileId}&fragment-id=${sharedFileFragmentId1}`,
"workspace/get-file-fragment-9056_shared-1.json",
);
await workspace.mockRPC(
`get-file-fragment?file-id=${sharedFileId}&fragment-id=${sharedFileFragmentId2}`,
"workspace/get-file-fragment-9056_shared-2.json",
);
await workspace.goToWorkspace({
fileId: "e179d9df-de35-80bf-8005-283bbd5516b0",
pageId: "e179d9df-de35-80bf-8005-283bbd5516b1",
});
await workspace.clickToggableLayer("Board");
await workspace.clickToggableLayer("Group");
await workspace.layers.getByText("A", { exact: true }).click();
await workspace.rightSidebar.getByRole("button", { name: /^A / }).click();
const search = workspace.rightSidebar.locator(
"#swap-component-search-filter",
);
await search.fill("rect");
await expect(
workspace.rightSidebar.getByText("There are no assets in this library yet"),
).toBeVisible();
await workspace.rightSidebar
.getByRole("combobox")
.filter({ hasText: "New File 10" })
.click();
await workspace.rightSidebar
.getByRole("option", { name: "published component" })
.click();
await expect(search).toHaveValue("rect");
await expect(
workspace.rightSidebar.getByText("Rectangle", { exact: true }),
).toBeVisible();
});

View File

@ -757,7 +757,9 @@
on-library-change
(mf/use-fn
(fn [id]
(swap! filters* assoc :file-id id :term "" :path "")))
;; Keep the search term: it describes what the user is looking
;; for, not where, so it applies to the newly selected library.
(swap! filters* assoc :file-id id :path "")))
on-search-term-change
(mf/use-fn