From 191a95c55c6546e69fb0a18350a6fb33276ba3bd Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 14 Dec 2024 15:51:52 -0800 Subject: [PATCH] Fix: maybe prevent unnecessary search suggestion calls --- src/components/quicklaunch.jsx | 2 +- src/components/widgets/search/search.jsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/quicklaunch.jsx b/src/components/quicklaunch.jsx index 9f55f973c..cf2ed813a 100644 --- a/src/components/quicklaunch.jsx +++ b/src/components/quicklaunch.jsx @@ -129,7 +129,7 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea useEffect(() => { const abortController = new AbortController(); - if (searchString.length === 0) setResults([]); + if (searchString.trim().length === 0) setResults([]); else { let newResults = servicesAndBookmarks.filter((r) => { const nameMatch = r.name.toLowerCase().includes(searchString); diff --git a/src/components/widgets/search/search.jsx b/src/components/widgets/search/search.jsx index c9391d355..5a7edc04b 100644 --- a/src/components/widgets/search/search.jsx +++ b/src/components/widgets/search/search.jsx @@ -94,6 +94,7 @@ export default function Search({ options }) { if ( options.showSearchSuggestions && (selectedProvider.suggestionUrl || options.suggestionUrl) && // custom providers pass url via options + query.trim().length > 0 && query.trim() !== searchSuggestions[0] ) { fetch(`/api/search/searchSuggestion?query=${encodeURIComponent(query)}&providerName=${selectedProvider.name}`, {