From 5faf62d6d1c18f65b3176acd02bb602094af40c4 Mon Sep 17 00:00:00 2001 From: Marvelous Felix Date: Mon, 27 Apr 2026 16:10:46 +0000 Subject: [PATCH] fix(search): add proper debouncing to prevent excessive API calls - Cancel pending timer on each keystroke using useRef - Set isLoading=true immediately on input for instant feedback - Execute filtering only after 300ms debounce settles - Show inline spinner in SearchBar during debounce delay - Hide clear button while loading to avoid layout shift Closes #search-debounce --- src/app/components/search/SearchBar.tsx | 6 +- src/app/hooks/useSearch.tsx | 87 ++++++++++++++----------- 2 files changed, 54 insertions(+), 39 deletions(-) diff --git a/src/app/components/search/SearchBar.tsx b/src/app/components/search/SearchBar.tsx index 893be491..e6c59f68 100644 --- a/src/app/components/search/SearchBar.tsx +++ b/src/app/components/search/SearchBar.tsx @@ -124,7 +124,11 @@ export const SearchBar: React.FC = ({ className, isExpanded = fa )} /> - {query && ( + {isLoading && query && ( +
+ )} + + {query && !isLoading && (