Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/canvas/workspace/example/ExampleCanvasDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ export function ExampleCanvasDialog({
}, []);

const busy = entries.some((entry) => isRunning(entry.id));
// A finished import already opened the example, so the dialog leaves on its
// own: keeping it up asked for a second click to reach what was just made.
const done = entries.some((entry) => statuses[entry.id]?.phase === "done");
const closeRef = useRef(onClose);
closeRef.current = onClose;
useEffect(() => {
if (!done) return;
const timer = window.setTimeout(() => closeRef.current(), 600);
return () => window.clearTimeout(timer);
}, [done]);

return (
<dialog
Expand Down
10 changes: 9 additions & 1 deletion tests/browser/example_canvas_picker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,15 @@ try {
await dialog.waitFor();
// The catalog ships with the app, so the rows carry its titles.
await dialog.getByText("图像创作示例画布", { exact: true }).waitFor();
await dialog.getByRole("button", { name: "关闭", exact: true }).first().click();
// Importing through the picker closes it on its own, so the imported canvas
// is reachable without a second click.
await dialog
.locator(".cw-example-item")
.filter({ hasText: "图像创作示例画布" })
.getByRole("button", { name: "下载并导入", exact: true })
.click();
await dialog.waitFor({ state: "hidden" });
await page.waitForFunction(() => document.querySelectorAll(".react-flow__node").length === 2);

// 3. A page instead of an archive is reported inline, and nothing is imported.
await page.unroute(samplePattern);
Expand Down
Loading