From 893ad5ffb9ca4b44b349cd9156d2775e5668d371 Mon Sep 17 00:00:00 2001 From: Justin Edelson Date: Fri, 15 Nov 2024 00:21:12 -0500 Subject: [PATCH] fix(plugins): support translations in local storage recent searches plugins (#1286) Closes #1285 --- .../createLocalStorageRecentSearchesPlugin.test.ts | 9 +++++++++ .../src/createLocalStorageRecentSearchesPlugin.ts | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/autocomplete-plugin-recent-searches/src/__tests__/createLocalStorageRecentSearchesPlugin.test.ts b/packages/autocomplete-plugin-recent-searches/src/__tests__/createLocalStorageRecentSearchesPlugin.test.ts index d1cfc3ebd..49fe424e8 100644 --- a/packages/autocomplete-plugin-recent-searches/src/__tests__/createLocalStorageRecentSearchesPlugin.test.ts +++ b/packages/autocomplete-plugin-recent-searches/src/__tests__/createLocalStorageRecentSearchesPlugin.test.ts @@ -54,12 +54,21 @@ describe('createLocalStorageRecentSearchesPlugin', () => { const plugin = createLocalStorageRecentSearchesPlugin({ key: 'autocomplete', limit: 3, + translations: { + fillQueryTitle: () => 'TEST', + }, }); expect(plugin.__autocomplete_pluginOptions).toEqual({ key: expect.any(String), limit: expect.any(Number), + translations: { + fillQueryTitle: expect.any(Function), + }, }); + expect( + plugin.__autocomplete_pluginOptions!.translations.fillQueryTitle() + ).toBe('TEST'); }); test('exposes an API', () => { diff --git a/packages/autocomplete-plugin-recent-searches/src/createLocalStorageRecentSearchesPlugin.ts b/packages/autocomplete-plugin-recent-searches/src/createLocalStorageRecentSearchesPlugin.ts index 4d77edde9..f5b498481 100644 --- a/packages/autocomplete-plugin-recent-searches/src/createLocalStorageRecentSearchesPlugin.ts +++ b/packages/autocomplete-plugin-recent-searches/src/createLocalStorageRecentSearchesPlugin.ts @@ -58,7 +58,7 @@ export function createLocalStorageRecentSearchesPlugin< >( options: LocalStorageRecentSearchesPluginOptions ): AutocompletePlugin> { - const { key, limit, transformSource, search, subscribe } = + const { key, limit, transformSource, search, subscribe, translations } = getOptions(options); const storage = createLocalStorage({ key: [LOCAL_STORAGE_KEY, key].join(':'), @@ -70,6 +70,7 @@ export function createLocalStorageRecentSearchesPlugin< transformSource, storage, subscribe, + translations, }); return {