mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-18 05:28:16 -06:00
Highlight menu group containing the active item
This commit is contained in:
parent
15385eeda5
commit
f864fc6e22
BIN
netbox/project-static/dist/netbox.js
vendored
BIN
netbox/project-static/dist/netbox.js
vendored
Binary file not shown.
BIN
netbox/project-static/dist/netbox.js.map
vendored
BIN
netbox/project-static/dist/netbox.js.map
vendored
Binary file not shown.
@ -209,17 +209,19 @@ class SideNav {
|
|||||||
const dropdownMenu = link.closest('.dropdown-menu') as Nullable<HTMLDivElement>;
|
const dropdownMenu = link.closest('.dropdown-menu') as Nullable<HTMLDivElement>;
|
||||||
if (isElement(dropdownMenu)) {
|
if (isElement(dropdownMenu)) {
|
||||||
// Find the closest `.nav-link`, which should be adjacent to the `.dropdown-menu` element.
|
// Find the closest `.nav-link`, which should be adjacent to the `.dropdown-menu` element.
|
||||||
|
const groupItem = dropdownMenu.parentElement;
|
||||||
const groupLink = dropdownMenu.parentElement?.querySelector('.nav-link');
|
const groupLink = dropdownMenu.parentElement?.querySelector('.nav-link');
|
||||||
if (isElement(groupLink)) {
|
if (isElement(groupLink) && isElement(groupItem)) {
|
||||||
groupLink.classList.add('active');
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'expand':
|
case 'expand':
|
||||||
groupLink.setAttribute('aria-expanded', 'true');
|
groupLink.setAttribute('aria-expanded', 'true');
|
||||||
|
groupItem.classList.add('active');
|
||||||
dropdownMenu.classList.add('show');
|
dropdownMenu.classList.add('show');
|
||||||
link.classList.add('active');
|
link.classList.add('active');
|
||||||
break;
|
break;
|
||||||
case 'collapse':
|
case 'collapse':
|
||||||
groupLink.setAttribute('aria-expanded', 'false');
|
groupLink.setAttribute('aria-expanded', 'false');
|
||||||
|
groupItem.classList.remove('active');
|
||||||
dropdownMenu.classList.remove('show');
|
dropdownMenu.classList.remove('show');
|
||||||
link.classList.remove('active');
|
link.classList.remove('active');
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user