fix(ui): Restrict sidebar initialization to the vertical navbar

initSideNav() matched every .navbar element, and
templates/base/layout.html puts that class on both the sidebar aside and
the top header, so a second SideNav was constructed for the header.
Scope the selector to .navbar-vertical, which is what the pre-Tabler
selector .sidenav did.

Widen the sidebar element type from HTMLDivElement to HTMLElement, since
the element the selector matches is an aside.

Fixes #22929
This commit is contained in:
Martin Hauser 2026-08-13 23:42:56 +02:00 committed by Jeremy Stretch
parent 6578541eee
commit 604653935c
3 changed files with 6 additions and 6 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,7 @@ class SideNav {
/**
* Sidenav container element.
*/
private base: HTMLDivElement;
private base: HTMLElement;
/**
* SideNav internal state manager.
@ -27,7 +27,7 @@ class SideNav {
*/
private sections: Section[] = [];
constructor(base: HTMLDivElement) {
constructor(base: HTMLElement) {
this.base = base;
this.state = new StateManager<NavState>(
{ pinned: true },
@ -314,7 +314,7 @@ class SideNav {
}
export function initSideNav(): void {
for (const sidenav of getElements<HTMLDivElement>('.navbar')) {
for (const sidenav of getElements<HTMLElement>('.navbar-vertical')) {
new SideNav(sidenav);
}
}