mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-18 05:28:16 -06:00
Fix designation of active menu item
This commit is contained in:
parent
f39447698e
commit
77dbf5c3f1
BIN
netbox/project-static/dist/netbox.css
vendored
BIN
netbox/project-static/dist/netbox.css
vendored
Binary file not shown.
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.
@ -204,7 +204,7 @@ class SideNav {
|
||||
* @param link Active nav link
|
||||
* @param action Expand or Collapse
|
||||
*/
|
||||
private activateLink(link: HTMLAnchorElement, action: 'expand' | 'collapse'): void {
|
||||
private activateLink(link: HTMLDivElement, action: 'expand' | 'collapse'): void {
|
||||
// Find the closest .collapse element, which should contain `link`.
|
||||
const collapse = link.closest('.collapse') as Nullable<HTMLDivElement>;
|
||||
if (isElement(collapse)) {
|
||||
@ -232,13 +232,16 @@ class SideNav {
|
||||
* Find any nav links with `href` attributes matching the current path, to determine which nav
|
||||
* link should be considered active.
|
||||
*/
|
||||
private *getActiveLinks(): Generator<HTMLAnchorElement> {
|
||||
for (const link of this.base.querySelectorAll<HTMLAnchorElement>(
|
||||
'.navbar-nav .nav .nav-item a.nav-link',
|
||||
private *getActiveLinks(): Generator<HTMLDivElement> {
|
||||
for (const menuitem of this.base.querySelectorAll<HTMLDivElement>(
|
||||
'ul.navbar-nav .nav-item .dropdown-item',
|
||||
)) {
|
||||
const href = new RegExp(link.href, 'gi');
|
||||
if (window.location.href.match(href)) {
|
||||
yield link;
|
||||
const link = menuitem.querySelector<HTMLAnchorElement>('a')
|
||||
if (link) {
|
||||
const href = new RegExp(link.href, 'gi');
|
||||
if (window.location.href.match(href)) {
|
||||
yield menuitem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -309,7 +312,7 @@ class SideNav {
|
||||
}
|
||||
|
||||
export function initSideNav(): void {
|
||||
for (const sidenav of getElements<HTMLDivElement>('.sidenav')) {
|
||||
for (const sidenav of getElements<HTMLDivElement>('.navbar')) {
|
||||
new SideNav(sidenav);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
// Transitional styling to ease migration of templates from NetBox v3.x
|
||||
@import 'transitional/cards';
|
||||
@import 'transitional/layout';
|
||||
@import 'transitional/navigation';
|
||||
@import 'transitional/tables';
|
||||
@import 'transitional/tabs';
|
||||
|
||||
|
23
netbox/project-static/styles/transitional/_navigation.scss
Normal file
23
netbox/project-static/styles/transitional/_navigation.scss
Normal file
@ -0,0 +1,23 @@
|
||||
// Navbar styling
|
||||
.navbar-vertical.navbar-expand-lg {
|
||||
.navbar-collapse {
|
||||
.dropdown-menu {
|
||||
.dropdown-item {
|
||||
|
||||
// Remove underline from nav menu items
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
// Style active menu item
|
||||
&.active {
|
||||
background-color: $gray-700;
|
||||
a {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user