From bd8e26d2ab527864129d5c4caef62e932ad0374e Mon Sep 17 00:00:00 2001 From: shuaiplus <2327005759@qq.com> Date: Sat, 28 Mar 2026 01:58:47 +0800 Subject: [PATCH] feat: add search clear functionality and improve search input styling --- webapp/src/components/VaultPage.tsx | 1 + .../src/components/vault/VaultListPanel.tsx | 35 +++++++--- webapp/src/lib/i18n.ts | 4 ++ webapp/src/styles.css | 68 ++++++++++++++++--- 4 files changed, 91 insertions(+), 17 deletions(-) diff --git a/webapp/src/components/VaultPage.tsx b/webapp/src/components/VaultPage.tsx index 6316d8a..c3a39a5 100644 --- a/webapp/src/components/VaultPage.tsx +++ b/webapp/src/components/VaultPage.tsx @@ -828,6 +828,7 @@ function folderName(id: string | null | undefined): string { sortMenuRef={sortMenuRef} listPanelRef={listPanelRef} onSearchInput={setSearchInput} + onClearSearch={() => setSearchInput('')} onSearchCompositionStart={() => setSearchComposing(true)} onSearchCompositionEnd={(value) => { setSearchComposing(false); diff --git a/webapp/src/components/vault/VaultListPanel.tsx b/webapp/src/components/vault/VaultListPanel.tsx index 0ac2607..0e46274 100644 --- a/webapp/src/components/vault/VaultListPanel.tsx +++ b/webapp/src/components/vault/VaultListPanel.tsx @@ -37,6 +37,7 @@ interface VaultListPanelProps { sortMenuRef: RefObject; listPanelRef: RefObject; onSearchInput: (value: string) => void; + onClearSearch: () => void; onSearchCompositionStart: () => void; onSearchCompositionEnd: (value: string) => void; onToggleSortMenu: () => void; @@ -62,14 +63,32 @@ export default function VaultListPanel(props: VaultListPanelProps) { return (
- props.onSearchInput((e.currentTarget as HTMLInputElement).value)} - onCompositionStart={props.onSearchCompositionStart} - onCompositionEnd={(e) => props.onSearchCompositionEnd((e.currentTarget as HTMLInputElement).value)} - /> +
+ props.onSearchInput((e.currentTarget as HTMLInputElement).value)} + onCompositionStart={props.onSearchCompositionStart} + onCompositionEnd={(e) => props.onSearchCompositionEnd((e.currentTarget as HTMLInputElement).value)} + onKeyDown={(e) => { + if (e.key !== 'Escape' || !props.searchInput) return; + e.preventDefault(); + props.onClearSearch(); + }} + /> + {!!props.searchInput && ( + + )} +