From df3007af25f1405ab907dba60f02cf65e167a263 Mon Sep 17 00:00:00 2001 From: g-but <41178744+g-but@users.noreply.github.com> Date: Sat, 16 May 2026 04:09:06 +0200 Subject: [PATCH] =?UTF-8?q?feat(people):=20Escape=20key=20resets=20search?= =?UTF-8?q?=20and=20health=20filter=20=E2=80=94=20global=20handler=20skips?= =?UTF-8?q?=20input=20focus,=20search=20input=20blurs=20on=20Escape?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- src/components/people/PeopleGrid.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/people/PeopleGrid.tsx b/src/components/people/PeopleGrid.tsx index 21dedbdba..881af9069 100644 --- a/src/components/people/PeopleGrid.tsx +++ b/src/components/people/PeopleGrid.tsx @@ -87,6 +87,18 @@ export function PeopleGrid({ return () => { clearTimeout(timer); ctrl.abort(); }; }, [query, sort, healthFilter, search]); + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key !== "Escape") return; + const tag = (e.target as HTMLElement).tagName; + if (tag === "INPUT" || tag === "TEXTAREA") return; + setQuery(""); + setHealthFilter([]); + }; + document.addEventListener("keydown", handleKeyDown); + return () => document.removeEventListener("keydown", handleKeyDown); + }, []); + function toggleHealth(h: RelationshipHealth) { setHealthFilter((prev) => prev.includes(h) ? prev.filter((x) => x !== h) : [...prev, h], @@ -123,6 +135,7 @@ export function PeopleGrid({ placeholder="Search people..." value={query} onChange={(e) => setQuery(e.target.value)} + onKeyDown={(e) => { if (e.key === "Escape") { setQuery(""); (e.target as HTMLInputElement).blur(); } }} className="ui-search-input" />