Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(editor): keep typed text sizes on unmount; reset only from the button
EtienneLescot70fd14d54aa2
diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsxindex 6df9ea156..1895a47e8 100644--- a/src/components/ai-edition/RightPanes.tsx+++ b/src/components/ai-edition/RightPanes.tsx@@ -4078,7 +4078,8 @@ export function SliderCell({* (Roundness sous un cadre) : l'infobulle du libellé et du slider. */hint?: string;/** The value a reset returns to, in the slider's own units. With it, a slider moved off it- * shows a reset button, and a double-click on the track does the same. */+ * shows a reset button. Not a double-click on the track: its two mouse-ups would each+ * commit, leaving intermediate values in the undo history before the reset. */defaultValue?: number;}) {const tc = useScopedT("common");@@ -4134,7 +4135,6 @@ export function SliderCell({onMouseUp={onCommit}onTouchEnd={onCommit}onKeyUp={onCommit}- onDoubleClick={reset}/></div>);diff --git a/src/components/ai-edition/SliderCell.test.tsx b/src/components/ai-edition/SliderCell.test.tsxindex 208202129..20fa5e6b7 100644--- a/src/components/ai-edition/SliderCell.test.tsx+++ b/src/components/ai-edition/SliderCell.test.tsx@@ -67,7 +67,7 @@ describe("SliderCell", () => {expect(cell?.className).toContain("full");});- it("offers a reset once the value has left its default, and resets on it or a double-click", () => {+ it("offers a reset once the value has left its default, and resets on it", () => {const onChange = vi.fn();const onCommit = vi.fn();const props = { label: "Shadow", min: 0, max: 100, suffix: "%", onChange, onCommit };@@ -78,9 +78,6 @@ describe("SliderCell", () => {fireEvent.click(screen.getByRole("button", { name: "actions.resetToDefault: Shadow" }));expect(onChange).toHaveBeenLastCalledWith(20);expect(onCommit).toHaveBeenCalledTimes(1);-- fireEvent.doubleClick(screen.getByRole("slider", { name: "Shadow" }));- expect(onCommit).toHaveBeenCalledTimes(2);});it("shows a number only when it has a unit", () => {diff --git a/src/components/ai-edition/v4/FloatingInspector.test.tsx b/src/components/ai-edition/v4/FloatingInspector.test.tsxindex 8d66456ec..b27d29424 100644--- a/src/components/ai-edition/v4/FloatingInspector.test.tsx+++ b/src/components/ai-edition/v4/FloatingInspector.test.tsx@@ -272,6 +272,14 @@ describe("AnnotationSizeField", () => {expect(commitTyped("big")).not.toHaveBeenCalled();});+ it("commits a typed size when the field unmounts before its blur", () => {+ const onCommit = vi.fn();+ const view = render(<AnnotationSizeField label="Size" size={32} onCommit={onCommit} />);+ fireEvent.change(view.getByRole("textbox", { name: "Size" }), { target: { value: "64" } });+ view.unmount();+ expect(onCommit).toHaveBeenCalledWith(64);+ });+it("commits a typed size read into its bound", () => {expect(commitTyped("0")).toHaveBeenCalledWith(8);expect(commitTyped("48")).toHaveBeenCalledWith(48);diff --git a/src/components/ai-edition/v4/FloatingInspector.tsx b/src/components/ai-edition/v4/FloatingInspector.tsxindex d117615fc..3e10abeb3 100644--- a/src/components/ai-edition/v4/FloatingInspector.tsx+++ b/src/components/ai-edition/v4/FloatingInspector.tsx@@ -665,14 +665,31 @@ export function AnnotationSizeField({}) {// "" means the field is idle and shows the live size as its placeholder.const [draft, setDraft] = useState("");+ /** The committed size a draft reads as, or null when it names none. */+ const sizeOf = (text: string) => {+ const typed = text.trim().replace(",", ".");+ // Empty or unparseable reverts to the live size rather than guessing at an intent.+ if (typed === "" || !Number.isFinite(Number(typed))) return null;+ return Math.round(clampToBound(Number(typed), "annotationFontSize"));+ };const commitDraft = () => {- const text = draft.trim().replace(",", ".");+ const next = sizeOf(draft);setDraft("");- // Empty or unparseable reverts to the live size rather than guessing at an intent.- if (text === "" || !Number.isFinite(Number(text))) return;- const next = Math.round(clampToBound(Number(text), "annotationFontSize"));- if (next !== size) onCommit(next);+ if (next !== null && next !== size) onCommit(next);};+ // A click on the timeline clears the selection on pointerdown, which unmounts this field+ // before its blur can fire. A size typed and never blurred is committed on the way out.+ const pendingRef = useRef({ draft, size, onCommit });+ pendingRef.current = { draft, size, onCommit };+ // biome-ignore lint/correctness/useExhaustiveDependencies: runs once, on unmount; the ref carries the latest draft.+ useEffect(+ () => () => {+ const { draft: left, size: live, onCommit: commit } = pendingRef.current;+ const next = sizeOf(left);+ if (next !== null && next !== live) commit(next);+ },+ [],+ );return (<inputtype="text"diff --git a/src/lib/ai-edition/document/migrate.test.ts b/src/lib/ai-edition/document/migrate.test.tsindex 681cf64e2..6fd417c5f 100644--- a/src/lib/ai-edition/document/migrate.test.ts+++ b/src/lib/ai-edition/document/migrate.test.ts@@ -235,10 +235,10 @@ describe("migrateProjectDataToAxcutDocument", () => {it("carries cursor tuning keys from a v2 editor into getEditorSettings", () => {const v2 = makeV2Project();- v2.editor.cursorSize = 0.3;+ v2.editor.cursorSize = 2.5;v2.editor.cursorClickBounce = 0;const settings = getEditorSettings(migrateProjectDataToAxcutDocument(v2));- expect(settings.cursor.size).toBe(0.3);+ expect(settings.cursor.size).toBe(2.5);expect(settings.cursor.clickBounce).toBe(0);});