Skip to content

Commit 893ad5f

Browse files
fix(plugins): support translations in local storage recent searches plugins (#1286)
Closes #1285
1 parent 8467b7a commit 893ad5f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/autocomplete-plugin-recent-searches/src/__tests__/createLocalStorageRecentSearchesPlugin.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,21 @@ describe('createLocalStorageRecentSearchesPlugin', () => {
5454
const plugin = createLocalStorageRecentSearchesPlugin({
5555
key: 'autocomplete',
5656
limit: 3,
57+
translations: {
58+
fillQueryTitle: () => 'TEST',
59+
},
5760
});
5861

5962
expect(plugin.__autocomplete_pluginOptions).toEqual({
6063
key: expect.any(String),
6164
limit: expect.any(Number),
65+
translations: {
66+
fillQueryTitle: expect.any(Function),
67+
},
6268
});
69+
expect(
70+
plugin.__autocomplete_pluginOptions!.translations.fillQueryTitle()
71+
).toBe('TEST');
6372
});
6473

6574
test('exposes an API', () => {

packages/autocomplete-plugin-recent-searches/src/createLocalStorageRecentSearchesPlugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function createLocalStorageRecentSearchesPlugin<
5858
>(
5959
options: LocalStorageRecentSearchesPluginOptions<TItem>
6060
): AutocompletePlugin<TItem, RecentSearchesPluginData<TItem>> {
61-
const { key, limit, transformSource, search, subscribe } =
61+
const { key, limit, transformSource, search, subscribe, translations } =
6262
getOptions(options);
6363
const storage = createLocalStorage<TItem>({
6464
key: [LOCAL_STORAGE_KEY, key].join(':'),
@@ -70,6 +70,7 @@ export function createLocalStorageRecentSearchesPlugin<
7070
transformSource,
7171
storage,
7272
subscribe,
73+
translations,
7374
});
7475

7576
return {

0 commit comments

Comments
 (0)