Themes: Switch back from throttling to debouncing in theme searches on admin screen.

Start debouncing after initial search performed when `search` query param is present to prevent initial "flash of unsearched themes".

Props afercia, westonruter.
Amends [41797].
See #40254.
Fixes #42348.

Built from https://develop.svn.wordpress.org/trunk@42029


git-svn-id: http://core.svn.wordpress.org/trunk@41863 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-10-27 03:31:53 +00:00
parent c6fd6b0374
commit 7b0de1f1b0
3 changed files with 13 additions and 7 deletions

View File

@ -102,6 +102,7 @@ themes.view.Appearance = wp.Backbone.View.extend({
collection: self.collection,
parent: this
});
self.searchView = view;
// Render and append after screen title
view.render();
@ -1347,12 +1348,12 @@ themes.view.Search = wp.Backbone.View.extend({
event.target.value = '';
}
// Note that doSearch is throttled.
// Since doSearch is debounced, it will only run when user input comes to a rest.
this.doSearch( event );
},
// Runs a search on the theme collection.
doSearch: _.throttle( function( event ) {
doSearch: function( event ) {
var options = {};
this.collection.doSearch( event.target.value.replace( /\+/g, ' ' ) );
@ -1370,7 +1371,7 @@ themes.view.Search = wp.Backbone.View.extend({
} else {
themes.router.navigate( themes.router.baseUrl( '' ) );
}
}, 500 ),
},
pushState: function( event ) {
var url = themes.router.baseUrl( '' );
@ -1445,6 +1446,9 @@ themes.Run = {
});
this.render();
// Start debouncing user searches after Backbone.history.start().
this.view.searchView.doSearch = _.debounce( this.view.searchView.doSearch, 500 );
},
render: function() {
@ -1520,7 +1524,7 @@ themes.view.InstallerSearch = themes.view.Search.extend({
this.doSearch( event.target.value );
},
doSearch: _.throttle( function( value ) {
doSearch: function( value ) {
var request = {};
// Don't do anything if the search terms haven't changed.
@ -1564,7 +1568,7 @@ themes.view.InstallerSearch = themes.view.Search.extend({
// Set route
themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + encodeURIComponent( value ) ), { replace: true } );
}, 500 )
}
});
themes.view.Installer = themes.view.Appearance.extend({
@ -1919,6 +1923,8 @@ themes.RunInstaller = {
// Render results
this.render();
// Start debouncing user searches after Backbone.history.start().
this.view.searchView.doSearch = _.debounce( this.view.searchView.doSearch, 500 );
},
render: function() {

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-beta4-42028';
$wp_version = '4.9-beta4-42029';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.