From 947cab458ca770f116d28a1f22687ae620e71b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thea=20Sch=C3=B6bl?= Date: Thu, 23 Mar 2023 09:06:21 +0000 Subject: [PATCH] fix: workaround for side menu items not being active on page load --- src/app/modules/menu/navigation/root-link.directive.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/modules/menu/navigation/root-link.directive.ts b/src/app/modules/menu/navigation/root-link.directive.ts index ea933589..28345a40 100644 --- a/src/app/modules/menu/navigation/root-link.directive.ts +++ b/src/app/modules/menu/navigation/root-link.directive.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 StApps + * Copyright (C) 2023 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -12,7 +12,6 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ - import {Directive, ElementRef, Input, OnDestroy, OnInit, Renderer2} from '@angular/core'; import {AnimationController, NavController} from '@ionic/angular'; import {Router, RouterEvent} from '@angular/router'; @@ -46,6 +45,12 @@ export class RootLinkDirective implements OnInit, OnDestroy { ngOnInit() { const animation = tabsTransition(this.animationController); this.renderer.setAttribute(this.element.nativeElement, 'button', ''); + if (document.querySelector('#main')?.childNodes.length === 1) { + if (this.router.url === this.rootLink) { + this.setActive(); + } + this.needsInit = false; + } this.subscriptions.push( this.router.events.subscribe(event => {