Making WordPress.org

Changeset 1311


Ignore:
Timestamp:
02/25/2015 12:16:05 AM (10 years ago)
Author:
obenland
Message:

WP.org Themes: Prevent empty search requests.

Only performs searches if the search value is not empty.
This prevents a race condition between the fallback query for featured themes
and the query for an empty search value, returning all themes.

See #745.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js

    r1299 r1311  
    580580
    581581    _.extend( wp.themes.view.InstallerSearch.prototype, {
     582        events: {
     583            'keyup':  'search',
     584            'search': 'search',
     585        },
     586
    582587        doSearch: _.debounce( function( value ) {
    583             var request = {},
    584                 sort = 'featured';
     588            var request = {};
    585589
    586590            request.search = value;
     
    607611            $( 'body' ).removeClass( 'show-filters filters-applied' );
    608612
    609             // Get the themes by sending Ajax POST request to api.wordpress.org/themes
    610             // or searching the local cache
    611             this.collection.query( request );
    612 
    613             // Set route
    614613            if ( value ) {
     614                // Get the themes by sending Ajax POST request to api.wordpress.org/themes
     615                // or searching the local cache
     616                this.collection.query( request );
     617
     618                // Set route
    615619                wp.themes.utils.title( value );
    616620                wp.themes.router.navigate( wp.themes.router.baseUrl( wp.themes.router.searchPath + value ), { replace: true } );
    617621            } else {
    618                 wp.themes.router.navigate( wp.themes.router.baseUrl( wp.themes.router.browsePath + sort ) );
    619                 this.parent.sort( sort );
     622                wp.themes.router.navigate( wp.themes.router.baseUrl( wp.themes.router.browsePath + 'featured' ), { trigger: true } );
    620623            }
    621624        }, 300 )
Note: See TracChangeset for help on using the changeset viewer.