From 212addacf8285459250eb343c0ab9a23d0300955 Mon Sep 17 00:00:00 2001 From: EtienneLescot Date: Sat, 22 Aug 2026 11:27:50 +0200 Subject: [PATCH] fix(editor): close the clip picker on an outside click It previously only closed by picking a clip or re-clicking the trigger, matching the mousedown-outside pattern EditorTopBar's LangButton already uses. Covers it with an e2e test. --- .../ai-edition/v4/FloatingInspector.tsx | 15 +++- tests/e2e/v4-shell.spec.ts | 73 ++++++++++++++++--- 2 files changed, 76 insertions(+), 12 deletions(-) diff --git a/src/components/ai-edition/v4/FloatingInspector.tsx b/src/components/ai-edition/v4/FloatingInspector.tsx index 2d3651a15..ac162d322 100644 --- a/src/components/ai-edition/v4/FloatingInspector.tsx +++ b/src/components/ai-edition/v4/FloatingInspector.tsx @@ -14,7 +14,7 @@ import { ZoomIn, } from "lucide-react"; import type { ComponentProps } from "react"; -import { useMemo, useRef, useState } from "react"; +import { useEffect, useMemo, useRef, useState } from "react"; import { toast } from "sonner"; import { parseCustomPlaybackSpeedInput } from "@/components/video-editor/customPlaybackSpeed"; import { @@ -101,6 +101,17 @@ export function FloatingInspector({ const ts = useScopedT("settings"); const te = useScopedT("editor"); const [clipPickerOpen, setClipPickerOpen] = useState(false); + const clipPickerRef = useRef(null); + useEffect(() => { + if (!clipPickerOpen) return; + const onDocMouseDown = (e: MouseEvent) => { + if (clipPickerRef.current && !clipPickerRef.current.contains(e.target as Node)) { + setClipPickerOpen(false); + } + }; + document.addEventListener("mousedown", onDocMouseDown); + return () => document.removeEventListener("mousedown", onDocMouseDown); + }, [clipPickerOpen]); const selection = tl.selection; const effectiveOpen = open || selection !== null; return ( @@ -136,7 +147,7 @@ export function FloatingInspector({ ))} -
+