diff --git a/plugins/woocommerce-admin/client/layout/controller.js b/plugins/woocommerce-admin/client/layout/controller.js index eb1a2d26bc3..0ed41786d50 100644 --- a/plugins/woocommerce-admin/client/layout/controller.js +++ b/plugins/woocommerce-admin/client/layout/controller.js @@ -31,13 +31,11 @@ const getPages = () => { container: DevDocs, path: '/devdocs', wpOpenMenu: 'toplevel_page_woocommerce', - wpClosedMenu: 'toplevel_page_wc-admin--analytics-revenue', } ); pages.push( { container: DevDocs, path: '/devdocs/:component', wpOpenMenu: 'toplevel_page_woocommerce', - wpClosedMenu: 'toplevel_page_wc-admin--analytics-revenue', } ); } @@ -46,7 +44,6 @@ const getPages = () => { container: Dashboard, path: '/', wpOpenMenu: 'toplevel_page_woocommerce', - wpClosedMenu: 'toplevel_page_wc-admin--analytics-revenue', } ); } @@ -55,19 +52,16 @@ const getPages = () => { container: Analytics, path: '/analytics', wpOpenMenu: 'toplevel_page_wc-admin--analytics-revenue', - wpClosedMenu: 'toplevel_page_woocommerce', } ); pages.push( { container: AnalyticsSettings, path: '/analytics/settings', wpOpenMenu: 'toplevel_page_wc-admin--analytics-revenue', - wpClosedMenu: 'toplevel_page_woocommerce', } ); pages.push( { container: AnalyticsReport, path: '/analytics/:report', wpOpenMenu: 'toplevel_page_wc-admin--analytics-revenue', - wpClosedMenu: 'toplevel_page_woocommerce', } ); } @@ -170,9 +164,9 @@ window.wpNavMenuUrlUpdate = function( page, query ) { ] ); const nextQuery = stringifyQuery( getPersistedQuery( query ) ); - Array.from( - document.querySelectorAll( `#${ page.wpOpenMenu } a, #${ page.wpClosedMenu } a` ) - ).forEach( item => updateLinkHref( item, nextQuery, excludedScreens ) ); + Array.from( document.querySelectorAll( '#adminmenu a' ) ).forEach( item => + updateLinkHref( item, nextQuery, excludedScreens ) + ); }; // When the route changes, we need to update wp-admin's menu with the correct section & current link @@ -209,14 +203,6 @@ window.wpNavMenuClassChange = function( page ) { currentMenu.classList.add( 'current' ); } - // Sometimes navigating from the subMenu to Dashboard does not close subMenu - if ( page.wpClosedMenu ) { - const closedMenu = document.querySelector( '#' + page.wpClosedMenu ); - closedMenu.classList.remove( 'wp-has-current-submenu' ); - closedMenu.classList.remove( 'wp-menu-open' ); - closedMenu.classList.add( 'wp-not-current-submenu' ); - } - const wpWrap = document.querySelector( '#wpwrap' ); wpWrap.classList.remove( 'wp-responsive-open' ); };