Skip to content

Commit 5b8de7f

Browse files
feat(query-suggestions): pass state to getSearchParams
1 parent 18c7474 commit 5b8de7f

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

packages/autocomplete-plugin-query-suggestions/src/createQuerySuggestionsPlugin.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { AutocompletePlugin } from '@algolia/autocomplete-core';
1+
import {
2+
AutocompletePlugin,
3+
AutocompleteState,
4+
} from '@algolia/autocomplete-core';
25
import {
36
getAlgoliaHits as defaultGetAlgoliaHits,
47
SourceTemplates,
@@ -17,7 +20,7 @@ export type CreateQuerySuggestionsPluginParams<
1720
> = {
1821
searchClient: SearchClient;
1922
indexName: string;
20-
getSearchParams?(): SearchOptions;
23+
getSearchParams?(params: { state: AutocompleteState<TItem> }): SearchOptions;
2124
getTemplates?(params: GetTemplatesParams<TItem>): SourceTemplates<TItem>;
2225
getAlgoliaHits?: typeof defaultGetAlgoliaHits;
2326
};
@@ -35,7 +38,7 @@ export function createQuerySuggestionsPlugin<
3538
undefined
3639
> {
3740
return {
38-
getSources({ query, setQuery, refresh }) {
41+
getSources({ query, setQuery, refresh, state }) {
3942
return [
4043
{
4144
getItemInputValue({ item }) {
@@ -48,7 +51,7 @@ export function createQuerySuggestionsPlugin<
4851
{
4952
indexName,
5053
query,
51-
params: getSearchParams(),
54+
params: getSearchParams({ state }),
5255
},
5356
],
5457
});

0 commit comments

Comments
 (0)