@@ -28,9 +28,17 @@ export interface AutocompletePromptProps<T> {
2828 abortSignal ?: AbortSignal
2929 infoMessage ?: InfoMessageProps [ 'message' ]
3030 groupOrder ?: string [ ]
31+ /**
32+ * Throttle window in milliseconds applied to the search callback. Defaults to 400ms,
33+ * which is appropriate for remote/paginated backends. In-memory consumers (where the
34+ * search callback resolves synchronously) can pass 0 for instant filtering on every
35+ * keystroke.
36+ */
37+ searchDebounceMs ?: number
3138}
3239
3340const MIN_NUMBER_OF_ITEMS_FOR_SEARCH = 5
41+ const DEFAULT_SEARCH_DEBOUNCE_MS = 400
3442
3543function AutocompletePrompt < T > ( {
3644 message,
@@ -42,6 +50,7 @@ function AutocompletePrompt<T>({
4250 abortSignal,
4351 infoMessage,
4452 groupOrder,
53+ searchDebounceMs = DEFAULT_SEARCH_DEBOUNCE_MS ,
4554} : React . PropsWithChildren < AutocompletePromptProps < T > > ) : ReactElement | null {
4655 const complete = useComplete ( )
4756 const [ searchTerm , setSearchTerm ] = useState ( '' )
@@ -121,10 +130,10 @@ function AutocompletePrompt<T>({
121130 clearTimeout ( setLoadingWhenSlow . current )
122131 } )
123132 } ,
124- 400 ,
133+ searchDebounceMs ,
125134 { leading : true , trailing : true } ,
126135 ) ,
127- [ paginatedSearch , setPromptState ] ,
136+ [ paginatedSearch , setPromptState , searchDebounceMs ] ,
128137 )
129138
130139 return (
0 commit comments