diff --git a/.changeset/wise-dryers-nail.md b/.changeset/wise-dryers-nail.md new file mode 100644 index 000000000..489e32acd --- /dev/null +++ b/.changeset/wise-dryers-nail.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Trim the search query to avoid showing a loading state when typing diff --git a/packages/gitbook/src/components/Search/SearchModal.tsx b/packages/gitbook/src/components/Search/SearchModal.tsx index d181393b6..bdc747241 100644 --- a/packages/gitbook/src/components/Search/SearchModal.tsx +++ b/packages/gitbook/src/components/Search/SearchModal.tsx @@ -189,6 +189,9 @@ function SearchModalBody( setSearchState((state) => (state ? { ...state, ask: true } : null)); }; + // We trim the query to avoid invalidating the search when the user is typing between words. + const normalizedQuery = state.query.trim(); + return ( ) : null} - {state.query && state.ask && withAsk ? : null} + {normalizedQuery && state.ask && withAsk ? ( + + ) : null} ); }