Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(editor): drop the zoom level row when no preset is within reach

EtienneLescot41df656cf6b9
diff --git a/src/components/ai-edition/v4/FloatingInspector.tsx b/src/components/ai-edition/v4/FloatingInspector.tsx
index 0189b5a2f..eef4ba15e 100644
--- a/src/components/ai-edition/v4/FloatingInspector.tsx
+++ b/src/components/ai-edition/v4/FloatingInspector.tsx
@@ -515,16 +515,19 @@ export function ZoomLevelControl({
return (
<>
- {/* A level outside the row presses no button; the field below shows it. */}
- {paneStack(
- ts("zoom.level"),
- <ChoiceRow<number>
- label={ts("zoom.level")}
- options={presets}
- value={requested}
- onChange={setScale}
- />,
- )}
+ {/* A level outside the row presses no button; the field below shows it. With no
+ preset within reach, the row goes and the field alone remains. */}
+ {presets.length > 0
+ ? paneStack(
+ ts("zoom.level"),
+ <ChoiceRow<number>
+ label={ts("zoom.level")}
+ options={presets}
+ value={requested}
+ onChange={setScale}
+ />,
+ )
+ : null}
{paneRow(
ts("zoom.customScale"),
<input
diff --git a/src/components/ai-edition/v4/ZoomLevelControl.test.tsx b/src/components/ai-edition/v4/ZoomLevelControl.test.tsx
index ac85473af..b3d238cea 100644
--- a/src/components/ai-edition/v4/ZoomLevelControl.test.tsx
+++ b/src/components/ai-edition/v4/ZoomLevelControl.test.tsx
@@ -142,6 +142,18 @@ describe("ZoomLevelControl", () => {
expect(updateZoomDepth).not.toHaveBeenCalled();
});
+ it("drops the row when no preset is within reach", () => {
+ render(
+ <ZoomLevelControl
+ region={{ id: "z1", depth: 1 }}
+ tl={{ updateZoomDepth: vi.fn(), updateZoomCustomScale }}
+ maxScale={1.3}
+ />,
+ );
+ expect(screen.queryByRole("group", { name: "zoom.level" })).toBeNull();
+ expect(screen.getByRole("textbox", { name: "zoom.customScale" })).toBeInTheDocument();
+ });
+
it("offers every level when all are within reach", () => {
renderControl(3);
expect(screen.getAllByRole("button")).toHaveLength(4);