From 8401b1362fd768cbc9d38d1b76ded024c5a106d0 Mon Sep 17 00:00:00 2001 From: Claire Chabas Date: Fri, 10 Jan 2025 20:03:51 +0100 Subject: [PATCH] testing --- packages/gitbook/src/components/Search/SearchResults.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/gitbook/src/components/Search/SearchResults.tsx b/packages/gitbook/src/components/Search/SearchResults.tsx index 259ac17fb..0a697669a 100644 --- a/packages/gitbook/src/components/Search/SearchResults.tsx +++ b/packages/gitbook/src/components/Search/SearchResults.tsx @@ -112,6 +112,13 @@ export const SearchResults = React.forwardRef(function SearchResults( }; } else { // setResultsState((prev) => ({ results: prev.results, fetching: true })); + console.log('CLAIRE BEFORE', resultsState); + setResultsState((prev) => { + if (prev.fetching) return prev; // Prevent redundant updates + return { results: prev.results, fetching: true }; + }); + console.log('CLAIRE AFTER', resultsState); + let cancelled = false; const timeout = setTimeout(async () => { const results = await (global @@ -139,7 +146,7 @@ export const SearchResults = React.forwardRef(function SearchResults( type: 'search_type_query', query, }); - }, 350); + }, 500); return () => { cancelled = true;