From 13896fc5de39d5e238b28c9a3710001acdf994d0 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Tue, 5 Jul 2016 14:37:06 +0000 Subject: [PATCH] Themes: Avoid announcing the theme search results too many times. Props afercia. Fixes #36848. git-svn-id: https://develop.svn.wordpress.org/trunk@37967 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/theme.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/js/theme.js b/src/wp-admin/js/theme.js index d532618585..7165540a39 100644 --- a/src/wp-admin/js/theme.js +++ b/src/wp-admin/js/theme.js @@ -1103,7 +1103,13 @@ themes.view.Themes = wp.Backbone.View.extend({ this.liveThemeCount = this.collection.count ? this.collection.count : this.collection.length; this.count.text( this.liveThemeCount ); - this.announceSearchResults( this.liveThemeCount ); + /* + * In the theme installer the themes count is already announced + * because `announceSearchResults` is called on `query:success`. + */ + if ( ! themes.isInstall ) { + this.announceSearchResults( this.liveThemeCount ); + } }, // Iterates through each instance of the collection @@ -1459,6 +1465,8 @@ themes.view.InstallerSearch = themes.view.Search.extend({ 'keyup': 'search' }, + terms: '', + // Handles Ajax request for searching through themes in public repo search: function( event ) { @@ -1480,6 +1488,14 @@ themes.view.InstallerSearch = themes.view.Search.extend({ doSearch: _.debounce( function( value ) { var request = {}; + // Don't do anything if the search terms haven't changed. + if ( this.terms === value ) { + return; + } + + // Updates terms with the value passed. + this.terms = value; + request.search = value; // Intercept an [author] search.