From 05320302b7219e79dca81b0bdd9edf8b7247dd90 Mon Sep 17 00:00:00 2001 From: Romain Ruaud Date: Mon, 7 Aug 2017 16:27:49 +0200 Subject: [PATCH] Adding debounce to autocomplete. --- .../view/frontend/web/js/form-mini.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/module-elasticsuite-core/view/frontend/web/js/form-mini.js b/src/module-elasticsuite-core/view/frontend/web/js/form-mini.js index 56a091323..c094ebac5 100644 --- a/src/module-elasticsuite-core/view/frontend/web/js/form-mini.js +++ b/src/module-elasticsuite-core/view/frontend/web/js/form-mini.js @@ -35,7 +35,8 @@ define([ responseFieldElements: 'dl dd', selectClass: 'selected', submitBtn: 'button[type="submit"]', - searchLabel: '[data-role=minisearch-label]' + searchLabel: '[data-role=minisearch-label]', + debounceTimer: 500 }, /** @@ -221,7 +222,7 @@ define([ * * @private */ - _onPropertyChange: function () { + _onPropertyChange: _.debounce(function () { var searchField = this.element, clonePosition = { position: 'absolute', @@ -308,7 +309,7 @@ define([ this._updateAriaHasPopup(false); this.element.removeAttr('aria-activedescendant'); } - }, + }, this.debounceTimer), /** * Executes when keys are pressed in the search input field. Performs specific actions