From 143d330ce31d8da99f0ca4657fa43bae2f2c00e5 Mon Sep 17 00:00:00 2001 From: Rich Lott / Artful Robot Date: Mon, 23 Jan 2023 15:18:14 +0000 Subject: [PATCH] Speed up SearchKit results loading by 800ms --- .../traits/searchDisplayBaseTrait.service.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ext/search_kit/ang/crmSearchDisplay/traits/searchDisplayBaseTrait.service.js b/ext/search_kit/ang/crmSearchDisplay/traits/searchDisplayBaseTrait.service.js index 94a92454b8..74c44df727 100644 --- a/ext/search_kit/ang/crmSearchDisplay/traits/searchDisplayBaseTrait.service.js +++ b/ext/search_kit/ang/crmSearchDisplay/traits/searchDisplayBaseTrait.service.js @@ -27,11 +27,8 @@ this.placeholders.push({}); } - this.getResults = _.debounce(function() { - $scope.$apply(function() { - ctrl.runSearch(); - }); - }, 800); + // _.debounce used here to trigger the initial search immediately but prevent subsequent launches within 800ms + this.getResults = _.debounce(ctrl.runSearch, 800, {leading: true, trailing: false}); // Update totalCount variable if used. // Integrations can pass in `total-count="somevar" to keep track of the number of results returned -- 2.25.1