Skip to content

Commit 8b509fe

Browse files
committed
MAGE-899 Fix start bug
1 parent 72c2758 commit 8b509fe

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

view/frontend/web/js/autocomplete.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,24 @@ define([
166166
options.debug = true;
167167
}
168168

169+
// DEPRECATED Do not use - Retained for backward compatibility but `algoliaHookBeforeAutocompleteStart` will be removed in a future version
170+
if (typeof algoliaHookBeforeAutocompleteStart === 'function') {
171+
console.warn(
172+
"Deprecated! You are using an old API for Algolia's front end hooks. " +
173+
'Please, replace your hook method with new hook API. ' +
174+
'More information you can find on https://www.algolia.com/doc/integration/magento-2/customize/custom-front-end-events/'
175+
);
176+
177+
const hookResult = algoliaHookBeforeAutocompleteStart(
178+
sources,
179+
options,
180+
searchClient
181+
);
182+
183+
sources = hookResult.shift();
184+
options = hookResult.shift();
185+
}
186+
169187
sources.forEach((data) => {
170188
if (!data.sourceId) {
171189
console.error(
@@ -544,27 +562,9 @@ define([
544562
* @param options
545563
* @returns the Algolia Autocomplete instance
546564
*/
547-
startAutocomplete(searchClient, sources, options) {
548-
// DEPRECATED Do not use - Retained for backward compatibility but `algoliaHookBeforeAutocompleteStart` will be removed in a future version
549-
if (typeof algoliaHookBeforeAutocompleteStart === 'function') {
550-
console.warn(
551-
"Deprecated! You are using an old API for Algolia's front end hooks. " +
552-
'Please, replace your hook method with new hook API. ' +
553-
'More information you can find on https://www.algolia.com/doc/integration/magento-2/customize/custom-front-end-events/'
554-
);
555-
556-
const hookResult = algoliaHookBeforeAutocompleteStart(
557-
sources,
558-
options,
559-
searchClient
560-
);
561-
562-
sources = hookResult.shift();
563-
options = hookResult.shift();
564-
}
565-
565+
startAutocomplete(options) {
566566
/** Bind autocomplete feature to the input */
567-
let algoliaAutocompleteInstance = autocomplete.autocomplete(options);
567+
const algoliaAutocompleteInstance = autocomplete.autocomplete(options);
568568
return algoliaCommon.triggerHooks(
569569
'afterAutocompleteStart',
570570
algoliaAutocompleteInstance

0 commit comments

Comments
 (0)