Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Studios: the first camera motion or effect picked keeps the studio on screen

Adarshb5d3839796e3
diff --git a/src/components/studio/studio-page.tsx b/src/components/studio/studio-page.tsx
index 05c41a9c..293a65e5 100644
--- a/src/components/studio/studio-page.tsx
+++ b/src/components/studio/studio-page.tsx
@@ -268,7 +268,7 @@ const ExampleTiles = memo(function ExampleTiles({ tiles }: { tiles: StudioExampl
bridge.pick(id);
// The move's card shows above the composer: back up to it, as the link's navigation would have.
window.scrollTo({ top: 0, behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth" });
- if (keyboard) requestAnimationFrame(() => composer?.querySelector<HTMLElement>("textarea, button")?.focus({ preventScroll: true }));
+ if (keyboard) requestAnimationFrame(() => (composer?.querySelector("textarea") ?? composer?.querySelector("button"))?.focus({ preventScroll: true }));
};
return (
<div ref={grid} className="grid grid-cols-2 gap-3 sm:grid-cols-4">
@@ -438,7 +438,12 @@ function StudioBody({ header, tabs, examples }: { header?: React.ReactNode; tabs
</button>
</div>
)}
- {!hasItems && <ActivePresetHeader />}
+ {/* Its own boundary: the card's code loads on the first pick, and only the card waits for it, not the whole studio. */}
+ {!hasItems && (
+ <Suspense fallback={null}>
+ <ActivePresetHeader />
+ </Suspense>
+ )}
<div data-composer className={cn("mx-auto w-full", hasItems ? "max-w-[800px]" : "max-w-[760px]")}>
<Composer docked={hasItems} />
</div>
diff --git a/tests/studio-examples.test.ts b/tests/studio-examples.test.ts
index 0d2921ed..195d95f6 100644
--- a/tests/studio-examples.test.ts
+++ b/tests/studio-examples.test.ts
@@ -95,7 +95,9 @@ describe("the studios' examples", () => {
expect(read("components", "studio", "composer.tsx")).toMatch(/bridgeRef\.pick = pickPreset;/);
// A tile picked from the keyboard hands its focus to its own studio's composer, not to a hidden studio's.
expect(page).toMatch(/closest\("\[data-studio\]"\)\?\.querySelector<HTMLElement>\("\[data-composer\]"\)/);
- expect(page).toMatch(/if \(keyboard\) requestAnimationFrame\(\(\) => composer\?\.querySelector<HTMLElement>\("textarea, button"\)\?\.focus\(\{ preventScroll: true \}\)\)/);
+ expect(page).toMatch(/if \(keyboard\) requestAnimationFrame\(\(\) => \(composer\?\.querySelector\("textarea"\) \?\? composer\?\.querySelector\("button"\)\)\?\.focus\(\{ preventScroll: true \}\)\)/);
expect(page).toMatch(/^\s+data-studio$/m);
+ // The first pick loads the move's card: only the card waits for its code, so the studio (and the focus) stays.
+ expect(page).toMatch(/<Suspense fallback=\{null\}>\s*<ActivePresetHeader \/>\s*<\/Suspense>/);
});
});