Skip to content

Commit

Permalink
feat(query-suggestions): pass state to getSearchParams
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Dec 8, 2020
1 parent 18c7474 commit 5b8de7f
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { AutocompletePlugin } from '@algolia/autocomplete-core';
import {
AutocompletePlugin,
AutocompleteState,
} from '@algolia/autocomplete-core';
import {
getAlgoliaHits as defaultGetAlgoliaHits,
SourceTemplates,
Expand All @@ -17,7 +20,7 @@ export type CreateQuerySuggestionsPluginParams<
> = {
searchClient: SearchClient;
indexName: string;
getSearchParams?(): SearchOptions;
getSearchParams?(params: { state: AutocompleteState<TItem> }): SearchOptions;
getTemplates?(params: GetTemplatesParams<TItem>): SourceTemplates<TItem>;
getAlgoliaHits?: typeof defaultGetAlgoliaHits;
};
Expand All @@ -35,7 +38,7 @@ export function createQuerySuggestionsPlugin<
undefined
> {
return {
getSources({ query, setQuery, refresh }) {
getSources({ query, setQuery, refresh, state }) {
return [
{
getItemInputValue({ item }) {
Expand All @@ -48,7 +51,7 @@ export function createQuerySuggestionsPlugin<
{
indexName,
query,
params: getSearchParams(),
params: getSearchParams({ state }),
},
],
});
Expand Down

0 comments on commit 5b8de7f

Please sign in to comment.