Make WordPress Core

Ticket #38365: 38365.diff

File 38365.diff, 1.3 KB (added by celloexpressions, 9 years ago)

If there's a more recent term than the one in the results, re-run the query with the new term.

  • src/wp-admin/js/customize-controls.js

     
    10791079                loading: false,
    10801080                fullyLoaded: false,
    10811081                term: '',
     1082                nextTerm: '',
    10821083                filterContainer: $(),
    10831084
    10841085                /**
     
    14111412                        request.done(function( data ) {
    14121413                                var themes = data.themes,
    14131414                                    themeControl, newThemeControls;
     1415
     1416                                // Stop and try again if the term changed.
     1417                                if ( section.nextTerm ) {
     1418                                        section.term = section.nextTerm;
     1419                                        section.nextTerm = '';
     1420                                        section.loading = false;
     1421                                        section.loadControls();
     1422                                        return;
     1423                                }
     1424
    14141425                                if ( 0 !== themes.length ) {
    14151426                                        newThemeControls = [];
    14161427                                        // Add controls for each theme.
     
    15451556                        if ( '' !== newTerm ) { // Empty term should not show any results.
    15461557                                // Run a new query, with loadControls handling paging, etc.
    15471558                                section.term = newTerm;
    1548                                 section.loadControls();
     1559                                if ( ! section.loading ) {
     1560                                        section.loadControls();
     1561                                } else {
     1562                                        section.nextTerm = newTerm; // This will reload with the newest term once the current batch is loaded.
     1563                                }
    15491564                                if ( ! section.expanded() ) {
    15501565                                        section.expand(); // Expand the section if it isn't expanded.
    15511566                                }