Make WordPress Core

Changeset 42029


Ignore:
Timestamp:
10/27/2017 03:30:27 AM (9 years ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/theme.js

    r41797 r42029  
    103103                        parent: this
    104104                });
     105                self.searchView = view;
    105106
    106107                // Render and append after screen title
    … …  
    13481349                }
    13491350
    1350                 // Note that doSearch is throttled.
     1351                // Since doSearch is debounced, it will only run when user input comes to a rest.
    13511352                this.doSearch( event );
    13521353        },
    13531354
    13541355        // Runs a search on the theme collection.
    1355         doSearch: _.throttle( function( event ) {
     1356        doSearch: function( event ) {
    13561357                var options = {};
    13571358
    … …  
    13711372                        themes.router.navigate( themes.router.baseUrl( '' ) );
    13721373                }
    1373         }, 500 ),
     1374        },
    13741375
    13751376        pushState: function( event ) {
    … …  
    14461447
    14471448                this.render();
     1449
     1450                // Start debouncing user searches after Backbone.history.start().
     1451                this.view.searchView.doSearch = _.debounce( this.view.searchView.doSearch, 500 );
    14481452        },
    14491453
    … …  
    15211525        },
    15221526
    1523         doSearch: _.throttle( function( value ) {
     1527        doSearch: function( value ) {
    15241528                var request = {};
    15251529
    … …  
    15651569                // Set route
    15661570                themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + encodeURIComponent( value ) ), { replace: true } );
    1567         }, 500 )
     1571        }
    15681572});
    15691573
    … …  
    19201924                this.render();
    19211925
     1926                // Start debouncing user searches after Backbone.history.start().
     1927                this.view.searchView.doSearch = _.debounce( this.view.searchView.doSearch, 500 );
    19221928        },
    19231929
Note: See TracChangeset for help on using the changeset viewer.