From dbeff06efa2c24ab575bb25237dcbc0124e4ca6f Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 12 Apr 2026 20:36:30 +0300 Subject: [PATCH] Search shotcut tweaks --- app/components/layout/GlobalSearch.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/components/layout/GlobalSearch.tsx b/app/components/layout/GlobalSearch.tsx index 3485379e6..8a0fdf877 100644 --- a/app/components/layout/GlobalSearch.tsx +++ b/app/components/layout/GlobalSearch.tsx @@ -224,7 +224,7 @@ function GlobalSearchContent({ useDebounce( () => { if (searchType === "weapons") return; - if (!query) return; + if (query.length < 3) return; fetcher.load( `/search?q=${encodeURIComponent(query)}&type=${searchType}&limit=10`, ); @@ -233,11 +233,11 @@ function GlobalSearchContent({ [query, searchType], ); - const results = fetcher.data?.results ?? []; - const hasQuery = query.length > 0; + const hasQuery = query.length >= 3; + const results = hasQuery ? (fetcher.data?.results ?? []) : []; const weaponResults = - searchType === "weapons" ? filterWeaponResults(query, t) : []; + searchType === "weapons" && hasQuery ? filterWeaponResults(query, t) : []; const recentWeapons: SelectedWeapon[] = searchType === "weapons" @@ -277,7 +277,7 @@ function GlobalSearchContent({ const handleQueryChange = (e: React.ChangeEvent) => { const value = e.target.value; - const separatorMatch = value.match(/^([a-zA-Z]+)\.(?=[a-zA-Z ]) ?/); + const separatorMatch = value.match(/^([a-zA-Z]+)\.$/); if (separatorMatch) { const typedPrefix = separatorMatch[1]; @@ -287,7 +287,7 @@ function GlobalSearchContent({ if (matchedType) { setSearchType(matchedType); setSelectedWeapon(null); - setQuery(value.slice(separatorMatch[0].length)); + setQuery(""); return; } }