diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig index 8841dd7a82d5..af0549ed7f1a 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig @@ -11,6 +11,7 @@ class SymfonyProfiler { constructor() { + this.#reorderMainMenuItems(); this.#createTabs(); this.#createTableSearchFields(); this.#createToggles(); @@ -18,6 +19,24 @@ this.#convertDateTimesToUserTimezone(); } + #reorderMainMenuItems() { + /* reorder the main menu items to always display first the non-disabled items */ + const mainMenuElement = document.querySelector('#menu-profiler'); + const firstDisabledMenuItem = mainMenuElement.querySelector('li a > span.disabled')?.parentNode?.parentNode; + + if (!firstDisabledMenuItem) { + return; + } + + const mainMenuItems = mainMenuElement.querySelectorAll('li'); + mainMenuItems.forEach(menuItem => { + const isDisabled = null !== menuItem.querySelector('a > span.disabled'); + if (!isDisabled) { + mainMenuElement.insertBefore(menuItem, firstDisabledMenuItem); + } + }); + } + #createTabs() { /* the accessibility options of this component have been defined according to: */ /* www.w3.org/WAI/ARIA/apg/example-index/tabs/tabs-manual.html */