Media: debounce the media grid search, avoiding duplicate requests.

Add a debounce wrapper to the media grid search handler. The search callback is now fired after a 300 ms typing pause.

Remove redundant handlers for 'search' and 'change', preventing multiple/duplicate search callbacks.

Props certainstrings, joemcgill, Kelderic, batmoo.
Fixes #38911.

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


git-svn-id: http://core.svn.wordpress.org/trunk@39997 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Adam Silverstein 2017-02-15 17:29:44 +00:00
parent ca44bbd134
commit e322b0eb77
3 changed files with 6 additions and 8 deletions

View File

@ -7085,9 +7085,7 @@ Search = wp.media.View.extend({
events: {
'input': 'search',
'keyup': 'search',
'change': 'search',
'search': 'search'
'keyup': 'search'
},
/**
@ -7098,13 +7096,13 @@ Search = wp.media.View.extend({
return this;
},
search: function( event ) {
search: _.debounce( function( event ) {
if ( event.target.value ) {
this.model.set( 'search', event.target.value );
} else {
this.model.unset('search');
}
}
}, 300 )
});
module.exports = Search;

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-40059';
$wp_version = '4.8-alpha-40060';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.