From d8eba3d2cc8519223cd7eb9ceaf3fa5688896078 Mon Sep 17 00:00:00 2001 From: Cagatay Civici Date: Wed, 26 Oct 2022 18:07:41 +0300 Subject: [PATCH] Fixed broken menu due to lint regression and route active class for menu --- src/app/layout/app.menu.component.ts | 2 +- src/app/layout/app.menuitem.component.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/layout/app.menu.component.ts b/src/app/layout/app.menu.component.ts index 148b11a..3bf7a65 100644 --- a/src/app/layout/app.menu.component.ts +++ b/src/app/layout/app.menu.component.ts @@ -34,7 +34,7 @@ export class AppMenuComponent implements OnInit { { label: 'Panel', icon: 'pi pi-fw pi-tablet', routerLink: ['/uikit/panel'] }, { label: 'Overlay', icon: 'pi pi-fw pi-clone', routerLink: ['/uikit/overlay'] }, { label: 'Media', icon: 'pi pi-fw pi-image', routerLink: ['/uikit/media'] }, - { label: 'Menu', icon: 'pi pi-fw pi-bars', routerLink: ['/uikit/menu'], preventExact: true }, + { label: 'Menu', icon: 'pi pi-fw pi-bars', routerLink: ['/uikit/menu'], routerLinkActiveOptions: { paths: 'subset', queryParams: 'ignored', matrixParams: 'ignored', fragment: 'ignored' } }, { label: 'Message', icon: 'pi pi-fw pi-comment', routerLink: ['/uikit/message'] }, { label: 'File', icon: 'pi pi-fw pi-file', routerLink: ['/uikit/file'] }, { label: 'Chart', icon: 'pi pi-fw pi-chart-bar', routerLink: ['/uikit/charts'] }, diff --git a/src/app/layout/app.menuitem.component.ts b/src/app/layout/app.menuitem.component.ts index 710dca3..ee34346 100644 --- a/src/app/layout/app.menuitem.component.ts +++ b/src/app/layout/app.menuitem.component.ts @@ -19,7 +19,7 @@ import { LayoutService } from './service/app.layout.service'; @@ -57,7 +57,7 @@ export class AppMenuitemComponent implements OnInit, OnDestroy { @Input() parentKey!: string; - @HostBinding('class.active-menuitem') active = false; + active = false; menuSourceSubscription: Subscription; @@ -131,6 +131,11 @@ export class AppMenuitemComponent implements OnInit, OnDestroy { return this.root ? 'expanded' : (this.active ? 'expanded' : 'collapsed'); } + @HostBinding('class.active-menuitem') + get activeClass() { + return this.active && !this.root; + } + ngOnDestroy() { if (this.menuSourceSubscription) { this.menuSourceSubscription.unsubscribe();