File tree 2 files changed +12
-2
lines changed
packages/gitbook/src/components/Search
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " gitbook " : patch
3
+ ---
4
+
5
+ Trim the search query to avoid showing a loading state when typing
Original file line number Diff line number Diff line change @@ -189,6 +189,9 @@ function SearchModalBody(
189
189
setSearchState ( ( state ) => ( state ? { ...state , ask : true } : null ) ) ;
190
190
} ;
191
191
192
+ // We trim the query to avoid invalidating the search when the user is typing between words.
193
+ const normalizedQuery = state . query . trim ( ) ;
194
+
192
195
return (
193
196
< motion . div
194
197
transition = { {
@@ -288,12 +291,14 @@ function SearchModalBody(
288
291
< SearchResults
289
292
ref = { resultsRef }
290
293
global = { isMultiVariants && state . global }
291
- query = { state . query }
294
+ query = { normalizedQuery }
292
295
withAsk = { withAsk }
293
296
onSwitchToAsk = { onSwitchToAsk }
294
297
/>
295
298
) : null }
296
- { state . query && state . ask && withAsk ? < SearchAskAnswer query = { state . query } /> : null }
299
+ { normalizedQuery && state . ask && withAsk ? (
300
+ < SearchAskAnswer query = { normalizedQuery } />
301
+ ) : null }
297
302
</ motion . div >
298
303
) ;
299
304
}
You can’t perform that action at this time.
0 commit comments