Skip to content

Commit daf9859

Browse files
committed
fix(editor): drop the zoom level row when no preset is within reach
1 parent 73694c0 commit daf9859

2 files changed

Lines changed: 25 additions & 10 deletions

File tree

‎src/components/ai-edition/v4/FloatingInspector.tsx‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -515,16 +515,19 @@ export function ZoomLevelControl({
515515

516516
return (
517517
<>
518-
{/* A level outside the row presses no button; the field below shows it. */}
519-
{paneStack(
520-
ts("zoom.level"),
521-
<ChoiceRow<number>
522-
label={ts("zoom.level")}
523-
options={presets}
524-
value={requested}
525-
onChange={setScale}
526-
/>,
527-
)}
518+
{/* A level outside the row presses no button; the field below shows it. With no
519+
preset within reach, the row goes and the field alone remains. */}
520+
{presets.length > 0
521+
? paneStack(
522+
ts("zoom.level"),
523+
<ChoiceRow<number>
524+
label={ts("zoom.level")}
525+
options={presets}
526+
value={requested}
527+
onChange={setScale}
528+
/>,
529+
)
530+
: null}
528531
{paneRow(
529532
ts("zoom.customScale"),
530533
<input

‎src/components/ai-edition/v4/ZoomLevelControl.test.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ describe("ZoomLevelControl", () => {
142142
expect(updateZoomDepth).not.toHaveBeenCalled();
143143
});
144144

145+
it("drops the row when no preset is within reach", () => {
146+
render(
147+
<ZoomLevelControl
148+
region={{ id: "z1", depth: 1 }}
149+
tl={{ updateZoomDepth: vi.fn(), updateZoomCustomScale }}
150+
maxScale={1.3}
151+
/>,
152+
);
153+
expect(screen.queryByRole("group", { name: "zoom.level" })).toBeNull();
154+
expect(screen.getByRole("textbox", { name: "zoom.customScale" })).toBeInTheDocument();
155+
});
156+
145157
it("offers every level when all are within reach", () => {
146158
renderControl(3);
147159
expect(screen.getAllByRole("button")).toHaveLength(4);

0 commit comments

Comments
 (0)