Skip to content

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

feat(inspector): four zoom presets and a free zoom field

EtienneLescot9ef83143b87c
diff --git a/src/components/ai-edition/v4/FloatingInspector.test.tsx b/src/components/ai-edition/v4/FloatingInspector.test.tsx
index 3602c283c..a71de4604 100644
--- a/src/components/ai-edition/v4/FloatingInspector.test.tsx
+++ b/src/components/ai-edition/v4/FloatingInspector.test.tsx
@@ -10,6 +10,7 @@ vi.mock("@/contexts/I18nContext", () => ({
vi.mock("../RightPanes", () => ({
AudioPane: () => <div data-testid="audio-pane">AudioPane</div>,
+ ChoiceRow: () => <div data-testid="choice-row">ChoiceRow</div>,
AudioTrackPane: ({ onClose }: { onClose?: () => void }) => (
<div data-testid="audio-track-pane">
AudioTrackPane
diff --git a/src/components/ai-edition/v4/FloatingInspector.tsx b/src/components/ai-edition/v4/FloatingInspector.tsx
index 5c0cc6867..6e1c952f8 100644
--- a/src/components/ai-edition/v4/FloatingInspector.tsx
+++ b/src/components/ai-edition/v4/FloatingInspector.tsx
@@ -30,9 +30,12 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { toast } from "sonner";
import { parseCustomPlaybackSpeedInput } from "@/components/video-editor/customPlaybackSpeed";
import {
+ effectiveZoomScale,
FIXED_ROTATION_3D_PRESETS,
isRotation3DPreset,
MAX_PLAYBACK_SPEED,
+ MAX_ZOOM_SCALE,
+ MIN_ZOOM_SCALE,
MOVING_ROTATION_3D_PRESETS,
type Rotation3DPreset,
ZOOM_DEPTH_SCALES,
@@ -431,137 +434,140 @@ function convertAnnotationKind(
const ZOOM_DEPTHS: readonly ZoomDepth[] = [1, 2, 3, 4, 5, 6];
+// The row: the default and one step either side, plus a strong close-up. The two ends of the
+// table (1.25×, 5×) and every level between are one entry in the free field below, which is
+// why the row stays short. Labels read the table, not a formula: a formula once announced
+// "2.0×" where the timeline pill showed "1.80×" and the render applied 1.8.
+const ZOOM_PRESETS = ([2, 3, 4, 5] as const).map((depth) => ({
+ value: ZOOM_DEPTH_SCALES[depth],
+ label: `${ZOOM_DEPTH_SCALES[depth]}×`,
+}));
+
/**
- * The six zoom levels as one row of buttons, so a level is one click away instead of two
- * (open the select, then pick). Six short labels fit the 300px pane on their own line, which
- * is why this is a stacked label/row rather than a `paneRow`.
+ * The zoom level as a row of presets plus a free field, the same pair as the speed control
+ * below. A level is one click away instead of two (open the select, then pick): that is
+ * My-Denia's change (#694), and so is everything that keeps rapid clicks and arrow steps in
+ * order, below.
*
- * `aria-pressed` buttons inside a labelled `role="group"` is `TranscriptLaneSwitch`'s pattern
- * (the facet rail is the same buttons without the wrapper, since its own label carries), so
- * every level stays in the Tab order and reads like its neighbours. Arrow keys step through
- * the levels, which is what the `<select>` this replaces did once focused — and the one
- * keyboard path that survives the editor shell's Tab binding (it cycles annotations whenever
- * any exist, from any focused element).
+ * The control speaks in scales, not depths: a preset and a typed level are the same kind of
+ * value, and a typed level the table has (1.8, or 1.25 which is not in the row) is written as
+ * its depth, so a document keeps naming its presets. Anything else is a `customScale`.
*/
export function ZoomLevelControl({
region,
tl,
}: {
- region: { id: string; depth: ZoomDepth };
- tl: Pick<TimelineApi, "updateZoomDepth">;
+ region: { id: string; depth: ZoomDepth; customScale?: number };
+ tl: Pick<TimelineApi, "updateZoomDepth" | "updateZoomCustomScale">;
}) {
const ts = useScopedT("settings");
- const buttonsRef = useRef<Array<HTMLButtonElement | null>>([]);
- // Last depth this instance asked for, and the generation of that request.
- // Depth values repeat (only 1–6), so a Set of depths cannot tell "our older
- // 4 landed" from "the latest request is 4" or from an undo that happens to
- // land on 4. Each click/key gets a new gen. Every gen belonging to this
- // region epoch is removed from `pending` when it settles — a superseded 4
- // must still drain, or `pending` stays non-empty and undo/redo can never
- // overwrite `requestedRef`. Only the latest gen may change `requestedRef`.
- const requestedRef = useRef<ZoomDepth>(region.depth);
+ const current = effectiveZoomScale(region);
+ // Last level this instance asked for, and the generation of that request. Levels repeat,
+ // so a set of levels cannot tell "our older 2.2 landed" from "the latest request is 2.2" or
+ // from an undo that happens to land on 2.2. Each click/key gets a new gen. Every gen
+ // belonging to this region epoch is removed from `pending` when it settles: a superseded
+ // request must still drain, or `pending` stays non-empty and undo/redo can never overwrite
+ // the request. Only the latest gen may change it.
+ //
+ // The row shows the request, not the document: its no-op guard compares against the value
+ // it is given, and against a document still saying 1.8 while a 2.2 is in flight, stepping
+ // back to 1.8 would be dropped as a re-press.
+ const requestedRef = useRef(current);
+ const [requested, setRequested] = useState(current);
const genRef = useRef(0);
const pendingRef = useRef(new Set<number>());
- const regionRef = useRef(region);
- regionRef.current = region;
+ const currentRef = useRef(current);
+ currentRef.current = current;
+ // "" means the field is idle and shows the live level as its placeholder.
+ const [draft, setDraft] = useState("");
- // biome-ignore lint/correctness/useExhaustiveDependencies: region.id is the trigger, not a read — the body resets request state; depth is taken from the render's ref so a same-depth other pill still clears the previous pill's pending gen.
+ // biome-ignore lint/correctness/useExhaustiveDependencies: region.id is the trigger, not a read — the body resets request state; the level is taken from the render's ref so a same-level other pill still clears the previous pill's pending gen.
useEffect(() => {
genRef.current += 1;
pendingRef.current.clear();
- requestedRef.current = regionRef.current.depth;
+ requestedRef.current = currentRef.current;
+ setRequested(currentRef.current);
}, [region.id]);
useEffect(() => {
if (pendingRef.current.size > 0) return;
- requestedRef.current = region.depth;
- }, [region.depth]);
+ requestedRef.current = current;
+ setRequested(current);
+ }, [current]);
- const setDepth = (depth: ZoomDepth) => {
- // Re-pressing the current level is not an edit: no save, no undo entry.
- if (depth === requestedRef.current) return;
- requestedRef.current = depth;
+ const setScale = (scale: number) => {
+ // Re-choosing the current level is not an edit: no save, no undo entry.
+ if (scale === requestedRef.current) return;
+ requestedRef.current = scale;
+ setRequested(scale);
const gen = ++genRef.current;
pendingRef.current.add(gen);
- const regionId = region.id;
- void Promise.resolve(tl.updateZoomDepth(regionId, depth)).then(
- (ok) => {
- pendingRef.current.delete(gen);
- if (gen !== genRef.current) return;
- if (ok === false) requestedRef.current = regionRef.current.depth;
- },
- () => {
- pendingRef.current.delete(gen);
- if (gen !== genRef.current) return;
- requestedRef.current = regionRef.current.depth;
- },
+ const depth = ZOOM_DEPTHS.find((d) => ZOOM_DEPTH_SCALES[d] === scale);
+ const write =
+ depth === undefined
+ ? tl.updateZoomCustomScale(region.id, scale)
+ : tl.updateZoomDepth(region.id, depth);
+ // A refused write hands the level back to the document, so the same one can be retried.
+ const settle = (ok: boolean) => {
+ pendingRef.current.delete(gen);
+ if (ok || gen !== genRef.current) return;
+ requestedRef.current = currentRef.current;
+ setRequested(currentRef.current);
+ };
+ void Promise.resolve(write).then(
+ (ok) => settle(ok !== false),
+ () => settle(false),
);
};
+ const commitDraft = () => {
+ const text = draft
+ .trim()
+ .replace(",", ".")
+ .replace(/\s*[×x]$/i, "");
+ setDraft("");
+ // Empty or unparseable reverts to the live level rather than guessing at an intent.
+ if (text === "" || !Number.isFinite(Number(text))) return;
+ const scale = Math.round(Number(text) * 100) / 100;
+ if (scale < MIN_ZOOM_SCALE || scale > MAX_ZOOM_SCALE) {
+ toast.error(ts("zoom.customScaleRange", { min: MIN_ZOOM_SCALE, max: MAX_ZOOM_SCALE }));
+ return;
+ }
+ setScale(scale);
+ };
+
return (
- <div style={{ display: "flex", flexDirection: "column", gap: 6 }}>
- <span style={{ fontSize: 12.5, color: "var(--fg-2)", fontWeight: 500 }}>
- {ts("zoom.level")}
- </span>
- <div
- role="group"
- aria-label={ts("zoom.level")}
- style={{ display: "flex", gap: 4 }}
- onKeyDown={(e) => {
- // A button activates on Enter and Space by itself — but the shell's play/pause
- // shortcut is Space on WINDOW, and it `preventDefault()`s the keydown, which
- // cancels that activation. Unstopped, Space on a level changed nothing and
- // started playback instead. Stop the keystroke here so the button keeps its own
- // key, and do NOT `preventDefault()` it, or the activation dies the same way.
- if (e.key === "Enter" || e.key === " ") {
- e.nativeEvent.stopPropagation();
- return;
- }
- const step =
- e.key === "ArrowRight" || e.key === "ArrowDown"
- ? 1
- : e.key === "ArrowLeft" || e.key === "ArrowUp"
- ? -1
- : 0;
- if (step === 0) return;
- // `nativeEvent.stopPropagation()`, not just the synthetic one: the editor shell
- // listens on WINDOW, above React's root container, and ArrowLeft/ArrowRight seek
- // the playhead there. Same reason as the pill's own keydown in V4Timeline.
- e.preventDefault();
- e.nativeEvent.stopPropagation();
- // Step from the FOCUSED button, not from the selected level. Every level is a Tab
- // stop, so the two can part company — and stepping from the selection then threw
- // focus across the row (ArrowRight on the last button landed it in the middle).
- // Focus moves one place and the level follows it; at either end neither moves.
- const focused = buttonsRef.current.findIndex((b) => b === document.activeElement);
- const from = focused >= 0 ? focused : ZOOM_DEPTHS.indexOf(requestedRef.current);
- const next = ZOOM_DEPTHS[from + step];
- if (next === undefined) return;
- buttonsRef.current[next - 1]?.focus();
- setDepth(next);
- }}
- >
- {ZOOM_DEPTHS.map((d) => {
- const pressed = d === region.depth;
- return (
- <button
- key={d}
- ref={(el) => {
- buttonsRef.current[d - 1] = el;
- }}
- type="button"
- aria-pressed={pressed}
- onClick={() => setDepth(d)}
- style={pressed ? zoomLevelPressedStyle : zoomLevelBtnStyle}
- >
- {/* La table, pas une formule : ce libellé annonçait « 2.0× » là où la pastille de la
- timeline affiche « 1.80× » et où le rendu applique 1.8. */}
- {ZOOM_DEPTH_SCALES[d]}×
- </button>
- );
- })}
- </div>
- </div>
+ <>
+ {/* A level outside the row presses no button; the field below shows it. */}
+ {paneStack(
+ ts("zoom.level"),
+ <ChoiceRow<number>
+ label={ts("zoom.level")}
+ options={ZOOM_PRESETS}
+ value={requested}
+ onChange={setScale}
+ />,
+ )}
+ {paneRow(
+ ts("zoom.customScale"),
+ <input
+ type="text"
+ inputMode="decimal"
+ aria-label={ts("zoom.customScale")}
+ placeholder={`${requested}×`}
+ value={draft}
+ onChange={(e) => setDraft(e.target.value)}
+ onBlur={commitDraft}
+ // Enter blurs, and the blur handler commits: one path, so a keyboard commit
+ // can't apply the same draft twice.
+ onKeyDown={(e) => {
+ if (e.key === "Enter") e.currentTarget.blur();
+ }}
+ className={shell.control}
+ style={{ width: 84, textAlign: "right" }}
+ />,
+ )}
+ </>
);
}
@@ -1214,30 +1220,6 @@ function SelectionPane({ tl, onClose }: { tl: TimelineApi; onClose: () => void }
* slab outshouted every setting above it. */
const PANE_BUTTON = `${shell.btn} ${shell.btnSecondary}`;
-// Six of these share the pane's 266px of content width, so each gets ~41px: enough for
-// "1.25×" at 12px with room either side, and no horizontal padding to lose.
-const zoomLevelBtnStyle: React.CSSProperties = {
- flex: "1 1 0",
- minWidth: 0,
- height: 28,
- padding: 0,
- borderRadius: 8,
- border: "1px solid var(--border)",
- background: "var(--surface)",
- color: "var(--fg-2)",
- font: "500 12px var(--font-display)",
- cursor: "pointer",
-};
-
-// Same signal as the pressed facet-rail button: accent text on the soft accent fill.
-const zoomLevelPressedStyle: React.CSSProperties = {
- ...zoomLevelBtnStyle,
- border: "1px solid var(--accent)",
- background: "var(--accent-soft)",
- color: "var(--accent)",
- fontWeight: 600,
-};
-
function FacetBody({
facet,
onCollapse,
diff --git a/src/components/ai-edition/v4/ZoomLevelControl.test.tsx b/src/components/ai-edition/v4/ZoomLevelControl.test.tsx
index eb18eba1d..7b76a663b 100644
--- a/src/components/ai-edition/v4/ZoomLevelControl.test.tsx
+++ b/src/components/ai-edition/v4/ZoomLevelControl.test.tsx
@@ -2,23 +2,36 @@
import "@testing-library/jest-dom";
import { act, fireEvent, render, screen } from "@testing-library/react";
import { useState } from "react";
-import { describe, expect, it, vi } from "vitest";
+import { beforeEach, describe, expect, it, vi } from "vitest";
import { ZOOM_DEPTH_SCALES, type ZoomDepth } from "@/components/video-editor/types";
// The pane is only reachable with a project open and a zoom region selected, so drive the
// control directly. The translator echoes keys, as in `SpeedControl.test.tsx`.
vi.mock("@/contexts/I18nContext", () => ({
- useScopedT: () => (key: string) => key,
+ useScopedT: () => (key: string, vars?: Record<string, unknown>) =>
+ vars ? `${key}:${Object.values(vars).join(",")}` : key,
}));
+const toastError = vi.fn();
+vi.mock("sonner", () => ({ toast: { error: (message: string) => toastError(message) } }));
+
import { ZoomLevelControl } from "./FloatingInspector";
-function renderControl(depth: ZoomDepth) {
- const updateZoomDepth = vi.fn(async () => true);
- render(<ZoomLevelControl region={{ id: "z1", depth }} tl={{ updateZoomDepth }} />);
+// Never reached by the preset tests: a scale the table has is written as its depth.
+const updateZoomCustomScale = vi.fn(async (_id: string, _scale: number) => true);
+
+function renderControl(depth: ZoomDepth, customScale?: number) {
+ const updateZoomDepth = vi.fn(async (_id: string, _depth: ZoomDepth) => true);
+ render(
+ <ZoomLevelControl
+ region={{ id: "z1", depth, customScale }}
+ tl={{ updateZoomDepth, updateZoomCustomScale }}
+ />,
+ );
const group = screen.getByRole("group", { name: "zoom.level" });
const buttons = screen.getAllByRole("button");
- return { updateZoomDepth, group, buttons };
+ const field = screen.getByRole("textbox", { name: "zoom.customScale" });
+ return { updateZoomDepth, group, buttons, field };
}
/**
@@ -35,6 +48,7 @@ function renderControlled(initial: ZoomDepth) {
<ZoomLevelControl
region={{ id: "z1", depth }}
tl={{
+ updateZoomCustomScale,
updateZoomDepth: (id, next) => {
// Synchronously, so the re-render lands inside the `fireEvent` that caused it:
// the next keystroke in a test then sees the same DOM a user's would.
@@ -49,30 +63,78 @@ function renderControlled(initial: ZoomDepth) {
render(<Harness />);
const group = screen.getByRole("group", { name: "zoom.level" });
const buttons = screen.getAllByRole("button");
- const focusLevel = (depth: ZoomDepth) => (buttons[depth - 1] as HTMLButtonElement).focus();
+ const focusLevel = (depth: ZoomDepth) => (buttons[depth - 2] as HTMLButtonElement).focus();
return { updateZoomDepth, group, buttons, focusLevel };
}
describe("ZoomLevelControl", () => {
- it("renders one button per depth, labelled with the table value, current one pressed", () => {
- const { buttons } = renderControl(3);
- expect(buttons).toHaveLength(6);
+ beforeEach(() => {
+ toastError.mockClear();
+ updateZoomCustomScale.mockClear();
+ });
+
+ it("renders four presets, labelled with the table value, current one pressed", () => {
+ const { buttons, field } = renderControl(3);
expect(buttons.map((b) => b.textContent)).toEqual(
- ([1, 2, 3, 4, 5, 6] as const).map((d) => `${ZOOM_DEPTH_SCALES[d]}×`),
+ ([2, 3, 4, 5] as const).map((d) => `${ZOOM_DEPTH_SCALES[d]}×`),
);
expect(buttons.map((b) => b.getAttribute("aria-pressed"))).toEqual([
- "false",
"false",
"true",
"false",
"false",
- "false",
]);
+ expect(field).toHaveAttribute("placeholder", "1.8×");
+ });
+
+ // The ends of the table and every custom level live in the field, not the row.
+ it("presses no preset for a level outside the row, and shows it in the field", () => {
+ const { buttons, field } = renderControl(3, 2.75);
+ expect(buttons.every((b) => b.getAttribute("aria-pressed") === "false")).toBe(true);
+ expect(field).toHaveAttribute("placeholder", "2.75×");
+ });
+
+ it("commits a typed level as a custom scale, on Enter or blur and only once", () => {
+ const { updateZoomDepth, field } = renderControl(3);
+ fireEvent.change(field, { target: { value: "2,5×" } });
+ fireEvent.keyDown(field, { key: "Enter" });
+ fireEvent.blur(field);
+ expect(updateZoomCustomScale).toHaveBeenCalledTimes(1);
+ expect(updateZoomCustomScale).toHaveBeenCalledWith("z1", 2.5);
+ expect(updateZoomDepth).not.toHaveBeenCalled();
+ expect(field).toHaveValue("");
+ });
+
+ // A document keeps naming its presets, whether they were clicked or typed.
+ it("writes a typed level the table has as its depth", () => {
+ const { updateZoomDepth, field } = renderControl(3);
+ fireEvent.change(field, { target: { value: "1.25" } });
+ fireEvent.blur(field);
+ expect(updateZoomDepth).toHaveBeenCalledWith("z1", 1);
+ expect(updateZoomCustomScale).not.toHaveBeenCalled();
+ });
+
+ it("refuses a level outside the renderer's range and says so", () => {
+ const { updateZoomDepth, field } = renderControl(3);
+ fireEvent.change(field, { target: { value: "8" } });
+ fireEvent.blur(field);
+ expect(toastError).toHaveBeenCalledWith("zoom.customScaleRange:1,5");
+ expect(updateZoomCustomScale).not.toHaveBeenCalled();
+ expect(updateZoomDepth).not.toHaveBeenCalled();
+ });
+
+ it("ignores an unparseable draft without touching the region", () => {
+ const { updateZoomDepth, field } = renderControl(3);
+ fireEvent.change(field, { target: { value: "abc" } });
+ fireEvent.blur(field);
+ expect(toastError).not.toHaveBeenCalled();
+ expect(updateZoomCustomScale).not.toHaveBeenCalled();
+ expect(updateZoomDepth).not.toHaveBeenCalled();
});
it("commits a level in one click", () => {
const { updateZoomDepth, buttons } = renderControl(3);
- fireEvent.click(buttons[4] as HTMLButtonElement);
+ fireEvent.click(buttons[3] as HTMLButtonElement);
expect(updateZoomDepth).toHaveBeenCalledTimes(1);
expect(updateZoomDepth).toHaveBeenCalledWith("z1", 5);
});
@@ -80,7 +142,7 @@ describe("ZoomLevelControl", () => {
it("does not write when the current level is clicked again", () => {
// A no-op edit would still land a save and an undo entry.
const { updateZoomDepth, buttons } = renderControl(3);
- fireEvent.click(buttons[2] as HTMLButtonElement);
+ fireEvent.click(buttons[1] as HTMLButtonElement);
expect(updateZoomDepth).not.toHaveBeenCalled();
});
@@ -90,20 +152,28 @@ describe("ZoomLevelControl", () => {
it("follows the region when the level is changed from elsewhere", async () => {
const updateZoomDepth = vi.fn(async (_id: string, _depth: ZoomDepth) => true);
const { rerender } = render(
- <ZoomLevelControl region={{ id: "z1", depth: 3 }} tl={{ updateZoomDepth }} />,
+ <ZoomLevelControl
+ region={{ id: "z1", depth: 3 }}
+ tl={{ updateZoomDepth, updateZoomCustomScale }}
+ />,
);
- fireEvent.click(screen.getAllByRole("button")[4] as HTMLButtonElement);
+ fireEvent.click(screen.getAllByRole("button")[3] as HTMLButtonElement);
expect(updateZoomDepth).toHaveBeenCalledWith("z1", 5);
await act(async () => {
// Let the request settle so the follow-effect is allowed to copy the prop.
});
// An undo lands on 2 instead of the 5 this control asked for.
- rerender(<ZoomLevelControl region={{ id: "z1", depth: 2 }} tl={{ updateZoomDepth }} />);
- fireEvent.click(screen.getAllByRole("button")[1] as HTMLButtonElement);
+ rerender(
+ <ZoomLevelControl
+ region={{ id: "z1", depth: 2 }}
+ tl={{ updateZoomDepth, updateZoomCustomScale }}
+ />,
+ );
+ fireEvent.click(screen.getAllByRole("button")[0] as HTMLButtonElement);
expect(updateZoomDepth).toHaveBeenCalledTimes(1);
- fireEvent.click(screen.getAllByRole("button")[4] as HTMLButtonElement);
+ fireEvent.click(screen.getAllByRole("button")[3] as HTMLButtonElement);
expect(updateZoomDepth).toHaveBeenCalledTimes(2);
expect(updateZoomDepth).toHaveBeenLastCalledWith("z1", 5);
});
@@ -113,27 +183,27 @@ describe("ZoomLevelControl", () => {
focusLevel(3);
fireEvent.keyDown(group, { key: "ArrowRight" });
expect(updateZoomDepth).toHaveBeenLastCalledWith("z1", 4);
- expect(buttons[3]).toHaveFocus();
+ expect(buttons[2]).toHaveFocus();
fireEvent.keyDown(group, { key: "ArrowDown" });
expect(updateZoomDepth).toHaveBeenLastCalledWith("z1", 5);
- expect(buttons[4]).toHaveFocus();
+ expect(buttons[3]).toHaveFocus();
fireEvent.keyDown(group, { key: "ArrowLeft" });
expect(updateZoomDepth).toHaveBeenLastCalledWith("z1", 4);
fireEvent.keyDown(group, { key: "ArrowUp" });
expect(updateZoomDepth).toHaveBeenLastCalledWith("z1", 3);
- expect(buttons[2]).toHaveFocus();
+ expect(buttons[1]).toHaveFocus();
expect(updateZoomDepth).toHaveBeenCalledTimes(4);
- expect(buttons[2]).toHaveAttribute("aria-pressed", "true");
+ expect(buttons[1]).toHaveAttribute("aria-pressed", "true");
});
// Every level is a Tab stop, so focus can sit on a level that is not the selected one.
// Counting from the selection there moved focus the wrong way across the row.
it("steps from the button that has focus, not from the selected level", () => {
const { updateZoomDepth, group, buttons, focusLevel } = renderControlled(2);
- focusLevel(5);
+ focusLevel(4);
fireEvent.keyDown(group, { key: "ArrowRight" });
- expect(buttons[5]).toHaveFocus();
- expect(updateZoomDepth).toHaveBeenCalledWith("z1", 6);
+ expect(buttons[3]).toHaveFocus();
+ expect(updateZoomDepth).toHaveBeenCalledWith("z1", 5);
});
// `updateZoomDepth` writes the document, so the pressed state only catches up a tick later.
@@ -147,6 +217,7 @@ describe("ZoomLevelControl", () => {
<ZoomLevelControl
region={{ id: "z1", depth }}
tl={{
+ updateZoomCustomScale,
updateZoomDepth: async (id, next) => {
await updateZoomDepth(id, next);
setDepth(next);
@@ -159,11 +230,11 @@ describe("ZoomLevelControl", () => {
render(<Harness />);
const group = screen.getByRole("group", { name: "zoom.level" });
const buttons = screen.getAllByRole("button");
- (buttons[2] as HTMLButtonElement).focus();
+ (buttons[1] as HTMLButtonElement).focus();
fireEvent.keyDown(group, { key: "ArrowRight" });
fireEvent.keyDown(group, { key: "ArrowRight" });
expect(updateZoomDepth.mock.calls.map(([, depth]) => depth)).toEqual([4, 5]);
- expect(buttons[4]).toHaveFocus();
+ expect(buttons[3]).toHaveFocus();
});
// The mirror image of the test above, and the one that catches a stale read: stepping
@@ -179,6 +250,7 @@ describe("ZoomLevelControl", () => {
<ZoomLevelControl
region={{ id: "z1", depth }}
tl={{
+ updateZoomCustomScale,
updateZoomDepth: async (id, next) => {
await updateZoomDepth(id, next);
setDepth(next);
@@ -191,11 +263,11 @@ describe("ZoomLevelControl", () => {
render(<Harness />);
const group = screen.getByRole("group", { name: "zoom.level" });
const buttons = screen.getAllByRole("button");
- (buttons[2] as HTMLButtonElement).focus();
+ (buttons[1] as HTMLButtonElement).focus();
fireEvent.keyDown(group, { key: "ArrowRight" });
fireEvent.keyDown(group, { key: "ArrowLeft" });
expect(updateZoomDepth.mock.calls.map(([, depth]) => depth)).toEqual([4, 3]);
- expect(buttons[2]).toHaveFocus();
+ expect(buttons[1]).toHaveFocus();
});
// `saveDocument` writes the returned document into the store and only then
@@ -216,6 +288,7 @@ describe("ZoomLevelControl", () => {
<ZoomLevelControl
region={{ id: "z1", depth }}
tl={{
+ updateZoomCustomScale,
updateZoomDepth: (id, next) => {
const pending = updateZoomDepth(id, next);
void pending.then(() => setDepth(next));
@@ -228,7 +301,7 @@ describe("ZoomLevelControl", () => {
render(<Harness />);
const group = screen.getByRole("group", { name: "zoom.level" });
const buttons = screen.getAllByRole("button");
- (buttons[2] as HTMLButtonElement).focus();
+ (buttons[1] as HTMLButtonElement).focus();
fireEvent.keyDown(group, { key: "ArrowRight" });
fireEvent.keyDown(group, { key: "ArrowRight" });
expect(updateZoomDepth.mock.calls.map(([, depth]) => depth)).toEqual([4, 5]);
@@ -237,12 +310,13 @@ describe("ZoomLevelControl", () => {
await act(async () => {
resolvers[0]!();
});
+ // The row shows the latest request, not the echo of the older one.
expect(buttons[3]).toHaveAttribute("aria-pressed", "true");
- expect(buttons[4]).toHaveFocus();
+ expect(buttons[3]).toHaveFocus();
fireEvent.keyDown(group, { key: "ArrowLeft" });
expect(updateZoomDepth.mock.calls.map(([, depth]) => depth)).toEqual([4, 5, 4]);
- expect(buttons[3]).toHaveFocus();
+ expect(buttons[2]).toHaveFocus();
});
// Depth values repeat, so an older request landing on 4 must not look like
@@ -261,6 +335,7 @@ describe("ZoomLevelControl", () => {
<ZoomLevelControl
region={{ id: "z1", depth }}
tl={{
+ updateZoomCustomScale,
updateZoomDepth: (id, next) => {
const pending = updateZoomDepth(id, next);
void pending.then(() => setDepth(next));
@@ -273,7 +348,7 @@ describe("ZoomLevelControl", () => {
render(<Harness />);
const group = screen.getByRole("group", { name: "zoom.level" });
const buttons = screen.getAllByRole("button");
- (buttons[2] as HTMLButtonElement).focus();
+ (buttons[1] as HTMLButtonElement).focus();
fireEvent.keyDown(group, { key: "ArrowRight" });
fireEvent.keyDown(group, { key: "ArrowRight" });
fireEvent.keyDown(group, { key: "ArrowLeft" });
@@ -285,20 +360,28 @@ describe("ZoomLevelControl", () => {
await act(async () => {
resolvers[1]!();
});
- fireEvent.click(buttons[4] as HTMLButtonElement);
+ fireEvent.click(buttons[3] as HTMLButtonElement);
expect(updateZoomDepth.mock.calls.map(([, depth]) => depth)).toEqual([4, 5, 4, 5]);
});
it("does not leak a pending request onto a different zoom region", async () => {
const updateZoomDepth = vi.fn(async (_id: string, _depth: ZoomDepth) => true);
const { rerender } = render(
- <ZoomLevelControl region={{ id: "A", depth: 3 }} tl={{ updateZoomDepth }} />,
+ <ZoomLevelControl
+ region={{ id: "A", depth: 3 }}
+ tl={{ updateZoomDepth, updateZoomCustomScale }}
+ />,
);
- fireEvent.click(screen.getAllByRole("button")[4] as HTMLButtonElement);
+ fireEvent.click(screen.getAllByRole("button")[3] as HTMLButtonElement);
expect(updateZoomDepth).toHaveBeenCalledWith("A", 5);
- rerender(<ZoomLevelControl region={{ id: "B", depth: 3 }} tl={{ updateZoomDepth }} />);
- fireEvent.click(screen.getAllByRole("button")[4] as HTMLButtonElement);
+ rerender(
+ <ZoomLevelControl
+ region={{ id: "B", depth: 3 }}
+ tl={{ updateZoomDepth, updateZoomCustomScale }}
+ />,
+ );
+ fireEvent.click(screen.getAllByRole("button")[3] as HTMLButtonElement);
expect(updateZoomDepth).toHaveBeenLastCalledWith("B", 5);
expect(updateZoomDepth).toHaveBeenCalledTimes(2);
});
@@ -306,49 +389,64 @@ describe("ZoomLevelControl", () => {
it("follows an undo after rapid steps have all settled", async () => {
const updateZoomDepth = vi.fn(async (_id: string, _depth: ZoomDepth) => true);
const { rerender } = render(
- <ZoomLevelControl region={{ id: "z1", depth: 3 }} tl={{ updateZoomDepth }} />,
+ <ZoomLevelControl
+ region={{ id: "z1", depth: 3 }}
+ tl={{ updateZoomDepth, updateZoomCustomScale }}
+ />,
);
const buttons = screen.getAllByRole("button");
+ fireEvent.click(buttons[2] as HTMLButtonElement);
fireEvent.click(buttons[3] as HTMLButtonElement);
- fireEvent.click(buttons[4] as HTMLButtonElement);
expect(updateZoomDepth.mock.calls.map(([, depth]) => depth)).toEqual([4, 5]);
await act(async () => {
// both generations must drain, or the follow-effect stays blocked
});
- rerender(<ZoomLevelControl region={{ id: "z1", depth: 4 }} tl={{ updateZoomDepth }} />);
- fireEvent.click(buttons[4] as HTMLButtonElement);
+ rerender(
+ <ZoomLevelControl
+ region={{ id: "z1", depth: 4 }}
+ tl={{ updateZoomDepth, updateZoomCustomScale }}
+ />,
+ );
+ fireEvent.click(buttons[3] as HTMLButtonElement);
expect(updateZoomDepth).toHaveBeenCalledTimes(3);
expect(updateZoomDepth).toHaveBeenLastCalledWith("z1", 5);
});
it("retries the same level after a failed save", async () => {
const updateZoomDepth = vi.fn(async (_id: string, _depth: ZoomDepth) => false);
- render(<ZoomLevelControl region={{ id: "z1", depth: 3 }} tl={{ updateZoomDepth }} />);
+ render(
+ <ZoomLevelControl
+ region={{ id: "z1", depth: 3 }}
+ tl={{ updateZoomDepth, updateZoomCustomScale }}
+ />,
+ );
const buttons = screen.getAllByRole("button");
- fireEvent.click(buttons[4] as HTMLButtonElement);
+ fireEvent.click(buttons[3] as HTMLButtonElement);
await act(async () => {
// settle the failed write so the same target is not stuck as current
});
- fireEvent.click(buttons[4] as HTMLButtonElement);
+ // The row hands the level back to the document while nothing is pending.
+ expect(buttons[1]).toHaveAttribute("aria-pressed", "true");
+ fireEvent.click(buttons[3] as HTMLButtonElement);
expect(updateZoomDepth).toHaveBeenCalledTimes(2);
expect(updateZoomDepth).toHaveBeenLastCalledWith("z1", 5);
});
it("clamps at the lowest level instead of wrapping", () => {
- const { updateZoomDepth, group, buttons, focusLevel } = renderControlled(1);
- focusLevel(1);
+ const { updateZoomDepth, group, buttons, focusLevel } = renderControlled(2);
+ focusLevel(2);
fireEvent.keyDown(group, { key: "ArrowLeft" });
expect(updateZoomDepth).not.toHaveBeenCalled();
expect(buttons[0]).toHaveFocus();
});
it("clamps at the highest level instead of wrapping", () => {
- const { updateZoomDepth, group, buttons, focusLevel } = renderControlled(6);
- focusLevel(6);
+ const { updateZoomDepth, group, buttons, focusLevel } = renderControlled(5);
+ focusLevel(5);
fireEvent.keyDown(group, { key: "ArrowRight" });
expect(updateZoomDepth).not.toHaveBeenCalled();
- expect(buttons[5]).toHaveFocus();
+ expect(buttons[3]).toHaveFocus();
});
it("keeps its own keys off the window listener, and lets every other key through", () => {
diff --git a/src/i18n/locales/ar/settings.json b/src/i18n/locales/ar/settings.json
index 100be30b1..88a9a32b9 100644
--- a/src/i18n/locales/ar/settings.json
+++ b/src/i18n/locales/ar/settings.json
@@ -384,6 +384,7 @@
"level": "مستوى التكبير",
"previewHold": "اضغط مع الاستمرار لمعاينة تأثير التكبير",
"customScale": "تكبير مخصص",
+ "customScaleRange": "يتراوح التكبير بين {{min}}× و{{max}}×",
"selectRegion": "حدد منطقة التكبير للتعديل",
"cursor": {
"title": "المؤشر",
diff --git a/src/i18n/locales/cs/settings.json b/src/i18n/locales/cs/settings.json
index e5e1be7f6..701c74a11 100644
--- a/src/i18n/locales/cs/settings.json
+++ b/src/i18n/locales/cs/settings.json
@@ -384,6 +384,7 @@
"level": "Úroveň přiblížení",
"previewHold": "Podržte pro náhled efektu přiblížení",
"customScale": "Vlastní přiblížení",
+ "customScaleRange": "Přiblížení může být od {{min}}× do {{max}}×",
"selectRegion": "Vyberte oblast přiblížení pro úpravu",
"cursor": {
"title": "Kurzor",
diff --git a/src/i18n/locales/de/settings.json b/src/i18n/locales/de/settings.json
index a2479ad90..4b7e19ad9 100644
--- a/src/i18n/locales/de/settings.json
+++ b/src/i18n/locales/de/settings.json
@@ -384,6 +384,7 @@
"level": "Zoomstufe",
"previewHold": "Gedrückt halten für die Zoom-Vorschau",
"customScale": "Eigener Zoom",
+ "customScaleRange": "Der Zoom reicht von {{min}}× bis {{max}}×",
"selectRegion": "Wähle einen Zoom-Bereich zum Anpassen",
"cursor": {
"title": "Cursor",
diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.json
index e4957152a..297b712ed 100644
--- a/src/i18n/locales/en/settings.json
+++ b/src/i18n/locales/en/settings.json
@@ -383,7 +383,8 @@
},
"level": "Zoom level",
"previewHold": "Hold to preview zoom effect",
- "customScale": "Custom Zoom",
+ "customScale": "Custom zoom",
+ "customScaleRange": "Zoom goes from {{min}}× to {{max}}×",
"selectRegion": "Select a zoom region to adjust",
"cursor": {
"title": "Cursor",
diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.json
index 16f5c7a79..890b41440 100644
--- a/src/i18n/locales/es/settings.json
+++ b/src/i18n/locales/es/settings.json
@@ -384,6 +384,7 @@
"level": "Nivel de zoom",
"previewHold": "Mantener para previsualizar el efecto de zoom",
"customScale": "Zoom personalizado",
+ "customScaleRange": "El zoom va de {{min}}× a {{max}}×",
"selectRegion": "Selecciona una región de zoom para ajustar",
"cursor": {
"title": "Cursor",
diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.json
index b8cb772a2..68e0e2233 100644
--- a/src/i18n/locales/fr/settings.json
+++ b/src/i18n/locales/fr/settings.json
@@ -384,6 +384,7 @@
"level": "Niveau de zoom",
"previewHold": "Maintenir pour prévisualiser l'effet de zoom",
"customScale": "Zoom personnalisé",
+ "customScaleRange": "Le zoom va de {{min}}× à {{max}}×",
"selectRegion": "Sélectionnez une région de zoom à ajuster",
"cursor": {
"title": "Curseur",
diff --git a/src/i18n/locales/it/settings.json b/src/i18n/locales/it/settings.json
index 23ad7a651..a0c13e5aa 100644
--- a/src/i18n/locales/it/settings.json
+++ b/src/i18n/locales/it/settings.json
@@ -384,6 +384,7 @@
"level": "Livello zoom",
"previewHold": "Tieni premuto per vedere l'anteprima dell'effetto zoom",
"customScale": "Zoom personalizzato",
+ "customScaleRange": "Lo zoom va da {{min}}× a {{max}}×",
"selectRegion": "Seleziona una regione zoom da regolare",
"cursor": {
"title": "Cursore",
diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.json
index 8e3a4dfdb..af5e3d177 100644
--- a/src/i18n/locales/ja-JP/settings.json
+++ b/src/i18n/locales/ja-JP/settings.json
@@ -384,6 +384,7 @@
"level": "ズーム倍率",
"previewHold": "押している間ズーム効果をプレビュー",
"customScale": "カスタムズーム",
+ "customScaleRange": "ズーム倍率は{{min}}×から{{max}}×までです",
"selectRegion": "ズーム範囲を選択して調整",
"cursor": {
"title": "カーソル",
diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.json
index 6a46098fc..7c556eb97 100644
--- a/src/i18n/locales/ko-KR/settings.json
+++ b/src/i18n/locales/ko-KR/settings.json
@@ -384,6 +384,7 @@
"level": "줌 레벨",
"previewHold": "누르고 있으면 줌 효과 미리보기",
"customScale": "커스텀 줌",
+ "customScaleRange": "줌은 {{min}}×에서 {{max}}×까지 가능합니다",
"selectRegion": "조정할 줌 구간을 선택하세요",
"cursor": {
"title": "커서",
diff --git a/src/i18n/locales/pt-BR/settings.json b/src/i18n/locales/pt-BR/settings.json
index 9cf5dc48e..398fa2839 100644
--- a/src/i18n/locales/pt-BR/settings.json
+++ b/src/i18n/locales/pt-BR/settings.json
@@ -384,6 +384,7 @@
"level": "Nível de Zoom",
"previewHold": "Mantenha pressionado para pré-visualizar o efeito de zoom",
"customScale": "Zoom Personalizado",
+ "customScaleRange": "O zoom vai de {{min}}× a {{max}}×",
"selectRegion": "Selecione uma região de zoom para ajustar",
"cursor": {
"title": "Cursor",
diff --git a/src/i18n/locales/ru/settings.json b/src/i18n/locales/ru/settings.json
index 89359ce7b..625a53605 100644
--- a/src/i18n/locales/ru/settings.json
+++ b/src/i18n/locales/ru/settings.json
@@ -384,6 +384,7 @@
"level": "Уровень масштабирования",
"previewHold": "Удерживайте для предпросмотра эффекта зума",
"customScale": "Пользовательский масштаб",
+ "customScaleRange": "Масштаб может быть от {{min}}× до {{max}}×",
"selectRegion": "Выберите область масштабирования для настройки",
"cursor": {
"title": "Курсор",
diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.json
index 46d43abec..206b2b7ca 100644
--- a/src/i18n/locales/tr/settings.json
+++ b/src/i18n/locales/tr/settings.json
@@ -384,6 +384,7 @@
"level": "Yakınlaştırma Seviyesi",
"previewHold": "Yakınlaştırma efektini önizlemek için basılı tutun",
"customScale": "Özel Yakınlaştırma",
+ "customScaleRange": "Yakınlaştırma {{min}}× ile {{max}}× arasında olabilir",
"selectRegion": "Ayarlamak için bir yakınlaştırma bölgesi seçin",
"cursor": {
"title": "İmleç",
diff --git a/src/i18n/locales/vi/settings.json b/src/i18n/locales/vi/settings.json
index 11c4ac50e..1aa15e103 100644
--- a/src/i18n/locales/vi/settings.json
+++ b/src/i18n/locales/vi/settings.json
@@ -384,6 +384,7 @@
"level": "Mức độ thu phóng",
"previewHold": "Giữ để xem trước hiệu ứng phóng to",
"customScale": "Thu phóng tùy chỉnh",
+ "customScaleRange": "Mức thu phóng từ {{min}}× đến {{max}}×",
"selectRegion": "Chọn vùng thu phóng để điều chỉnh",
"cursor": {
"title": "Con trỏ",
diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.json
index d18fd8d46..b34912793 100644
--- a/src/i18n/locales/zh-CN/settings.json
+++ b/src/i18n/locales/zh-CN/settings.json
@@ -384,6 +384,7 @@
"level": "缩放级别",
"previewHold": "按住预览放大效果",
"customScale": "自定义缩放",
+ "customScaleRange": "缩放范围为 {{min}}× 到 {{max}}×",
"selectRegion": "选择要调整的缩放区域",
"cursor": {
"title": "光标",
diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.json
index 66b592ed5..d8b84fafc 100644
--- a/src/i18n/locales/zh-TW/settings.json
+++ b/src/i18n/locales/zh-TW/settings.json
@@ -384,6 +384,7 @@
"level": "縮放級別",
"previewHold": "按住預覽放大效果",
"customScale": "自訂縮放",
+ "customScaleRange": "縮放範圍為 {{min}}× 到 {{max}}×",
"selectRegion": "選擇要調整的縮放區域",
"cursor": {
"title": "游標",
diff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.ts
index 5fd041c42..3848b5ff1 100644
--- a/src/lib/ai-edition/store/useTimeline.test.ts
+++ b/src/lib/ai-edition/store/useTimeline.test.ts
@@ -1233,6 +1233,25 @@ describe("useTimeline undo history", () => {
expect(useProjectStore.getState().document?.zoomRanges[0]?.depth).toBe(4);
});
+ // A custom scale overrides the depth, so a preset that left it in place would change a
+ // field the render never reads.
+ it("clamps a custom zoom level to the renderer's range, and a preset clears it", async () => {
+ seed(docWithZoom);
+ const { result } = renderTimeline();
+
+ await act(async () => {
+ await result.current.updateZoomCustomScale("zoom_a", 9);
+ });
+ expect(useProjectStore.getState().document?.zoomRanges[0]?.customScale).toBe(5);
+
+ await act(async () => {
+ await result.current.updateZoomDepth("zoom_a", 4);
+ });
+ const zoom = useProjectStore.getState().document?.zoomRanges[0];
+ expect(zoom?.depth).toBe(4);
+ expect(zoom?.customScale).toBeUndefined();
+ });
+
it("keeps a pending zoom level when the 3D tilt is changed before it lands", async () => {
seed(docWithZoom);
const gate = gateFirstSave();
diff --git a/src/lib/ai-edition/store/useTimeline.ts b/src/lib/ai-edition/store/useTimeline.ts
index 37796941c..d47d1a4a4 100644
--- a/src/lib/ai-edition/store/useTimeline.ts
+++ b/src/lib/ai-edition/store/useTimeline.ts
@@ -42,6 +42,7 @@ import {
resolvePillIds,
} from "../timeline/timelineMap";
import { dropTrimPillsByIds, resolveTimelineSpanToTrim } from "../timeline/trim-mapping";
+import { MAX_ZOOM_SCALE, MIN_ZOOM_SCALE } from "../timeline/zoom-scale";
import type { AutoZoomSuggestion } from "../timeline/zoom-suggestions";
import { saveWithDeadline, useProjectStore, waitForDocumentSaves } from "./projectStore";
import { currentWriteEpoch } from "./undoStack";
@@ -775,11 +776,19 @@ export function useTimeline() {
[enqueueZoomWrite, saveDocument],
);
- // Zoom-level control for the region-settings panel (1-6, matches
- // zoomRegionSchema's depth literal union — 1.0x..3.5x in 0.5x steps per
- // the `depth/2 + 0.5` label formula used throughout the timeline UI).
+ // A preset level (`ZOOM_DEPTH_SCALES`, 1.25×–5×). It clears any custom scale, which
+ // would otherwise keep overriding the depth: the level picked is the level rendered.
const updateZoomDepth = useCallback(
- (id: string, depth: 1 | 2 | 3 | 4 | 5 | 6) => saveZoomPatch(id, { depth }),
+ (id: string, depth: 1 | 2 | 3 | 4 | 5 | 6) =>
+ saveZoomPatch(id, { depth, customScale: undefined }),
+ [saveZoomPatch],
+ );
+
+ // Any other level, from the pane's free field. Clamped to the renderer's range here, so no
+ // caller can store a scale that `effectiveZoomScale` would then read differently.
+ const updateZoomCustomScale = useCallback(
+ (id: string, scale: number) =>
+ saveZoomPatch(id, { customScale: Math.min(MAX_ZOOM_SCALE, Math.max(MIN_ZOOM_SCALE, scale)) }),
[saveZoomPatch],
);
@@ -1569,6 +1578,7 @@ export function useTimeline() {
updateZoomFocusLive,
commitZoomFocus,
updateZoomDepth,
+ updateZoomCustomScale,
updateZoomRotation,
updateZoomFocusMode,
updateZoomHideCursor,
diff --git a/tests/e2e/v4-shell.spec.ts b/tests/e2e/v4-shell.spec.ts
index 79c1dd4b4..5b060112d 100644
--- a/tests/e2e/v4-shell.spec.ts
+++ b/tests/e2e/v4-shell.spec.ts
@@ -287,7 +287,7 @@ test.describe("v4 editor shell", () => {
await page.locator('[class*="lanePill"][title="1.80×"]').first().click();
const levels = page.getByRole("group", { name: "Zoom Level" }).getByRole("button");
- await expect(levels).toHaveCount(6);
+ await expect(levels).toHaveCount(4);
// One row inside the 300px pane, with every label intact: the reason this control
// stacks its own label instead of sitting in a `paneRow` like its neighbours.
@@ -312,21 +312,28 @@ test.describe("v4 editor shell", () => {
);
expect(await depth()).toBe(3);
- await levels.nth(3).focus(); // 2.2×, depth 4
+ await levels.nth(2).focus(); // 2.2×, depth 4
await page.keyboard.press("Space");
await expect.poll(depth).toBe(4);
- await expect(levels.nth(3)).toBeFocused();
+ await expect(levels.nth(2)).toBeFocused();
// Arrows step from the focused level, not from the selected one: every level is a
- // Tab stop, so ArrowRight on the last button has nowhere to go — and must not throw
+ // Tab stop, so ArrowLeft on the first button has nowhere to go — and must not throw
// focus back across the row to wherever the selection happens to be.
- await levels.nth(5).focus();
- await page.keyboard.press("ArrowRight");
- await expect(levels.nth(5)).toBeFocused();
- expect(await depth()).toBe(4);
+ await levels.nth(0).focus();
await page.keyboard.press("ArrowLeft");
- await expect.poll(depth).toBe(5);
- await expect(levels.nth(4)).toBeFocused();
+ await expect(levels.nth(0)).toBeFocused();
+ expect(await depth()).toBe(4);
+ await page.keyboard.press("ArrowRight");
+ await expect.poll(depth).toBe(3);
+ await expect(levels.nth(1)).toBeFocused();
+
+ // Any other level goes through the free field, and then no preset is pressed.
+ const custom = page.getByRole("textbox", { name: "Custom zoom" });
+ await custom.fill("2.5");
+ await custom.press("Enter");
+ await expect(page.locator('[class*="lanePill"][title="2.50×"]')).toHaveCount(1);
+ await expect(levels.and(page.locator('[aria-pressed="true"]'))).toHaveCount(0);
});
test("clicking outside the clip picker popover closes it", async ({ page }) => {