diff --git a/src/js/_enqueues/wp/theme.js b/src/js/_enqueues/wp/theme.js index dabd64cc6c6ba..7c1a3138ecd6c 100644 --- a/src/js/_enqueues/wp/theme.js +++ b/src/js/_enqueues/wp/theme.js @@ -1781,8 +1781,9 @@ themes.view.Installer = themes.view.Appearance.extend({ $( 'body' ).removeClass( 'filters-applied show-filters' ); $( '.drawer-toggle' ).attr( 'aria-expanded', 'false' ); - // Bail if this is already active. + // Bail if this is already active, restoring the URL if the filter drawer changed it. if ( $el.hasClass( this.activeClass ) ) { + themes.router.navigate( themes.router.baseUrl( themes.router.browsePath + sort ) ); return; } diff --git a/tests/qunit/index.html b/tests/qunit/index.html index f9033a776151c..e622566001f73 100644 --- a/tests/qunit/index.html +++ b/tests/qunit/index.html @@ -92,6 +92,14 @@ + + + diff --git a/tests/qunit/wp-admin/js/theme.js b/tests/qunit/wp-admin/js/theme.js index d82b26e1521db..cd82eecef5a95 100644 --- a/tests/qunit/wp-admin/js/theme.js +++ b/tests/qunit/wp-admin/js/theme.js @@ -135,4 +135,51 @@ assert.equal( prevCalled, 0, 'Ctrl+Left does nothing' ); } ); } ); + QUnit.module( 'Theme Installer sorting', function( hooks ) { + var originalRouter, originalSort, originalClearSearch, navigated, view; + + hooks.beforeEach( function() { + navigated = []; + originalRouter = _.clone( wp.themes.router ); + wp.themes.router.browsePath = '?browse='; + wp.themes.router.baseUrl = function( url ) { + return 'theme-install.php' + url; + }; + wp.themes.router.navigate = function( url ) { + navigated.push( url ); + }; + + $( '#qunit-fixture' ).html( + '