Skip to content

Commit d28ba35

Browse files
committed
MAGE-899 expose constants for override via mixins
1 parent cd1721b commit d28ba35

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

view/frontend/web/js/autocomplete.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ define([
4848
};
4949

5050
return Component.extend({
51+
DEFAULT_HITS_PER_SECTION,
52+
DEBOUNCE_MS,
53+
MIN_SEARCH_LENGTH_CHARS,
54+
5155
initialize(config, element) {
5256
// console.log('AC initialized with', config, element);
5357
this.buildAutocomplete($);
@@ -99,7 +103,7 @@ define([
99103
},
100104

101105
buildAutocompleteOptions(searchClient, sources, plugins) {
102-
const debounced = this.debounce(items => Promise.resolve(items), DEBOUNCE_MS);
106+
const debounced = this.debounce(items => Promise.resolve(items), this.DEBOUNCE_MS);
103107

104108
let options = algoliaCommon.triggerHooks('beforeAutocompleteOptions', {});
105109

@@ -123,7 +127,7 @@ define([
123127
return this.filterMinChars(query, debounced(this.transformSources(searchClient, sources)));
124128
},
125129
shouldPanelOpen: ({state}) => {
126-
return state.query.length >= MIN_SEARCH_LENGTH_CHARS;
130+
return state.query.length >= this.MIN_SEARCH_LENGTH_CHARS;
127131
},
128132
// Set debug to true, to be able to remove keyboard and be able to scroll in autocomplete menu
129133
debug: algoliaCommon.isMobile(),
@@ -265,7 +269,7 @@ define([
265269
*/
266270
buildAutocompleteSourceDefault(section) {
267271
const options = {
268-
hitsPerPage : section.hitsPerPage || DEFAULT_HITS_PER_SECTION,
272+
hitsPerPage : section.hitsPerPage || this.DEFAULT_HITS_PER_SECTION,
269273
analyticsTags : 'autocomplete',
270274
clickAnalytics: true,
271275
distinct : true,

0 commit comments

Comments
 (0)