From 38c5932aa96a860d713e0b3939e95639d474a327 Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Fri, 10 Jul 2026 08:02:43 +0800 Subject: [PATCH] Fix command palette escape in fullscreen (#1008) --- src/ui/shell/CommandPalette.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ui/shell/CommandPalette.tsx b/src/ui/shell/CommandPalette.tsx index 4af2c573..28e1180a 100644 --- a/src/ui/shell/CommandPalette.tsx +++ b/src/ui/shell/CommandPalette.tsx @@ -126,14 +126,18 @@ export function CommandPalette({ }, [isOpen]); useEffect(() => { + if (!isOpen) return; + const handleKeyDown = (e: KeyboardEvent) => { if (e.key === "Escape") { + e.preventDefault(); + e.stopPropagation(); setIsOpen(false); } }; - window.addEventListener("keydown", handleKeyDown); - return () => window.removeEventListener("keydown", handleKeyDown); - }, [setIsOpen]); + window.addEventListener("keydown", handleKeyDown, true); + return () => window.removeEventListener("keydown", handleKeyDown, true); + }, [isOpen, setIsOpen]); const filteredHosts = hosts.filter( (h) =>