From: Alexander Ebert Date: Thu, 23 Jun 2022 16:31:05 +0000 (+0200) Subject: Detect active menu items that have no children X-Git-Tag: 5.5.0_RC_3~19 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d78a85d0cde1aeb07c9fee3077bad3618cf358b1;p=GitHub%2FWoltLab%2FWCF.git Detect active menu items that have no children Links with children have the `active` class set on them, but links without have it placed on the parent instead. See https://www.woltlab.com/community/thread/296045-mobiles-hauptmen%C3%BC-teilweise-nicht-vorausgew%C3%A4hlt-wenn-man-auf-einer-unterseite-is/ --- diff --git a/ts/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.ts b/ts/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.ts index c06a2b47cb..8a8e576e54 100644 --- a/ts/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.ts +++ b/ts/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.ts @@ -29,8 +29,13 @@ function getMenuItems(category: HTMLOListElement): MenuItem[] { return Array.from(category.querySelectorAll(".acpPageSubMenuLink")).map((link: HTMLAnchorElement) => { const children = getMenuItemActions(link); + let active = link.classList.contains("active"); + if (children.length === 0 && link.parentElement!.classList.contains("active")) { + active = true; + } + return { - active: link.classList.contains("active"), + active, children, counter: 0, depth: 2, diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.js index 3044adbb9f..43ba1d4373 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Menu/Main/Backend.js @@ -27,8 +27,12 @@ define(["require", "exports"], function (require, exports) { function getMenuItems(category) { return Array.from(category.querySelectorAll(".acpPageSubMenuLink")).map((link) => { const children = getMenuItemActions(link); + let active = link.classList.contains("active"); + if (children.length === 0 && link.parentElement.classList.contains("active")) { + active = true; + } return { - active: link.classList.contains("active"), + active, children, counter: 0, depth: 2,