mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@40060 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -21,9 +21,7 @@ Search = wp.media.View.extend({
|
||||
|
||||
events: {
|
||||
'input': 'search',
|
||||
'keyup': 'search',
|
||||
'change': 'search',
|
||||
'search': 'search'
|
||||
'keyup': 'search'
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -34,13 +32,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;
|
||||
|
||||
Reference in New Issue
Block a user