From a6130fc687becece8c9bf4d7bc698ef4db0d3d09 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Tue, 19 May 2026 20:48:12 +0200 Subject: [PATCH] fix(ui): handle enter and escape in search The search field should behave like a transient launcher search control. Enter now blurs the input while preserving the current term, and Escape clears the term before blurring the input. Test Plan: - git diff --check Refs: user redesign nitpick about search keyboard behavior --- .../src/components/topbar/SearchField.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/lanspread-tauri-deno-ts/src/components/topbar/SearchField.tsx b/crates/lanspread-tauri-deno-ts/src/components/topbar/SearchField.tsx index 0a8afbf..d93c05b 100644 --- a/crates/lanspread-tauri-deno-ts/src/components/topbar/SearchField.tsx +++ b/crates/lanspread-tauri-deno-ts/src/components/topbar/SearchField.tsx @@ -26,6 +26,8 @@ export const SearchField = ({ value, onChange }: Props) => { return () => window.removeEventListener('keydown', onKey); }, []); + const blurInput = () => inputRef.current?.blur(); + return (
@@ -35,6 +37,16 @@ export const SearchField = ({ value, onChange }: Props) => { placeholder="Search games" value={value} onChange={(e) => onChange(e.target.value)} + onKeyDown={(e) => { + if (e.key === 'Enter') { + e.preventDefault(); + blurInput(); + } else if (e.key === 'Escape') { + e.preventDefault(); + onChange(''); + blurInput(); + } + }} spellCheck={false} /> /