From 9461f575321af68a7a3e1467973cf260710d7561 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 30 Oct 2017 03:56:26 +0000 Subject: [PATCH] Customize: Debounce requests for theme searches and the updating of the resulting filter count. Props celloexpressions. See #37661. Fixes #42343. git-svn-id: https://develop.svn.wordpress.org/trunk@42040 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-controls.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 881bf2492d..0504891969 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -1680,6 +1680,7 @@ nextTags: '', filtersHeight: 0, headerContainer: null, + updateCountDebounced: null, /** * Initialize. @@ -1696,6 +1697,7 @@ section.$window = $( window ); section.$body = $( document.body ); api.Section.prototype.initialize.call( section, id, options ); + section.updateCountDebounced = _.debounce( section.updateCount, 500 ); }, /** @@ -1869,7 +1871,6 @@ if ( ! section.expanded() ) { section.expand(); } - section.checkTerm( section ); }); // Feature filters. @@ -2240,7 +2241,7 @@ api.reflowPaneContents(); // Update theme count. - section.updateCount( count ); + section.updateCountDebounced( count ); }, /** @@ -2255,7 +2256,7 @@ var newTerm; if ( 'remote' === section.params.filter_type ) { newTerm = section.contentContainer.find( '.wp-filter-search' ).val(); - if ( section.term !== newTerm ) { + if ( section.term !== newTerm.trim() ) { section.initializeNewQuery( newTerm, section.tags ); } }