Skip to content

Commit f340351

Browse files
committed
feature symfony#54420 [WebProfilerBundle] Update main menu to display active panels first (javiereguiluz)
This PR was squashed before being merged into the 7.1 branch. Discussion ---------- [WebProfilerBundle] Update main menu to display active panels first | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | - | License | MIT I propose to reorder the main menu items to always display first the active panels, which are the ones that users will click. | Before | After | ------ | ----- | <img width="274" alt="" src="https://github.com/symfony/symfony/assets/73419/fa2edf53-4f83-4a87-8f41-a87d41138f54"> | <img width="270" alt="" src="https://github.com/symfony/symfony/assets/73419/81e8d450-186d-446e-8947-6c2205dc27e1"> Commits ------- 05e9192 [WebProfilerBundle] Update main menu to display active panels first
2 parents fc97603 + 05e9192 commit f340351

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,32 @@
1111
1212
class SymfonyProfiler {
1313
constructor() {
14+
this.#reorderMainMenuItems();
1415
this.#createTabs();
1516
this.#createTableSearchFields();
1617
this.#createToggles();
1718
this.#createCopyToClipboard();
1819
this.#convertDateTimesToUserTimezone();
1920
}
2021
22+
#reorderMainMenuItems() {
23+
/* reorder the main menu items to always display first the non-disabled items */
24+
const mainMenuElement = document.querySelector('#menu-profiler');
25+
const firstDisabledMenuItem = mainMenuElement.querySelector('li a > span.disabled')?.parentNode?.parentNode;
26+
27+
if (!firstDisabledMenuItem) {
28+
return;
29+
}
30+
31+
const mainMenuItems = mainMenuElement.querySelectorAll('li');
32+
mainMenuItems.forEach(menuItem => {
33+
const isDisabled = null !== menuItem.querySelector('a > span.disabled');
34+
if (!isDisabled) {
35+
mainMenuElement.insertBefore(menuItem, firstDisabledMenuItem);
36+
}
37+
});
38+
}
39+
2140
#createTabs() {
2241
/* the accessibility options of this component have been defined according to: */
2342
/* www.w3.org/WAI/ARIA/apg/example-index/tabs/tabs-manual.html */

0 commit comments

Comments
 (0)