From 8164b732397b701861422255074d6b658c7c1da9 Mon Sep 17 00:00:00 2001 From: yjl9903 Date: Sat, 5 Oct 2024 00:02:42 +0800 Subject: [PATCH] fix(web): reset search bar input --- apps/frontend/web/app/components/Search/Search.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/frontend/web/app/components/Search/Search.tsx b/apps/frontend/web/app/components/Search/Search.tsx index 2e843abf..e2008fee 100644 --- a/apps/frontend/web/app/components/Search/Search.tsx +++ b/apps/frontend/web/app/components/Search/Search.tsx @@ -18,7 +18,7 @@ import { useActiveElement, useDocument, useEventListener } from '@/hooks'; import './cmdk.css'; -import { DMHY_RE, debounce, parseSearch, resolveSearchURL } from './utils'; +import { DMHY_RE, debounce, parseSearch, resolveSearchURL, stringifySearch } from './utils'; const SEARCH_HELP_URL = `https://animespace.onekuma.cn/animegarden/search.html`; @@ -50,7 +50,8 @@ export const Search = memo(() => { useEffect(() => { if (location.state?.trigger !== 'search') { - setInput(''); + const content = stringifySearch(new URLSearchParams(location.search)); + setInput(content); } }, [location]);