Skip to content

Commit d8eba3d

Browse files
committed
Fixed broken menu due to lint regression and route active class for menu
1 parent 39e8809 commit d8eba3d

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/app/layout/app.menu.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class AppMenuComponent implements OnInit {
3434
{ label: 'Panel', icon: 'pi pi-fw pi-tablet', routerLink: ['/uikit/panel'] },
3535
{ label: 'Overlay', icon: 'pi pi-fw pi-clone', routerLink: ['/uikit/overlay'] },
3636
{ label: 'Media', icon: 'pi pi-fw pi-image', routerLink: ['/uikit/media'] },
37-
{ label: 'Menu', icon: 'pi pi-fw pi-bars', routerLink: ['/uikit/menu'], preventExact: true },
37+
{ label: 'Menu', icon: 'pi pi-fw pi-bars', routerLink: ['/uikit/menu'], routerLinkActiveOptions: { paths: 'subset', queryParams: 'ignored', matrixParams: 'ignored', fragment: 'ignored' } },
3838
{ label: 'Message', icon: 'pi pi-fw pi-comment', routerLink: ['/uikit/message'] },
3939
{ label: 'File', icon: 'pi pi-fw pi-file', routerLink: ['/uikit/file'] },
4040
{ label: 'Chart', icon: 'pi pi-fw pi-chart-bar', routerLink: ['/uikit/charts'] },

src/app/layout/app.menuitem.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { LayoutService } from './service/app.layout.service';
1919
<i class="pi pi-fw pi-angle-down layout-submenu-toggler" *ngIf="item.items"></i>
2020
</a>
2121
<a *ngIf="(item.routerLink && !item.items) && item.visible !== false" (click)="itemClick($event)" [ngClass]="item.class"
22-
[routerLink]="item.routerLink" routerLinkActive="active-route" [routerLinkActiveOptions]="item.routerLinkOptions||{exact: true}"
22+
[routerLink]="item.routerLink" routerLinkActive="active-route" [routerLinkActiveOptions]="item.routerLinkActiveOptions||{exact: true}"
2323
[fragment]="item.fragment" [queryParamsHandling]="item.queryParamsHandling" [preserveFragment]="item.preserveFragment"
2424
[skipLocationChange]="item.skipLocationChange" [replaceUrl]="item.replaceUrl" [state]="item.state" [queryParams]="item.queryParams"
2525
[attr.target]="item.target" tabindex="0" pRipple>
@@ -57,7 +57,7 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
5757

5858
@Input() parentKey!: string;
5959

60-
@HostBinding('class.active-menuitem') active = false;
60+
active = false;
6161

6262
menuSourceSubscription: Subscription;
6363

@@ -131,6 +131,11 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
131131
return this.root ? 'expanded' : (this.active ? 'expanded' : 'collapsed');
132132
}
133133

134+
@HostBinding('class.active-menuitem')
135+
get activeClass() {
136+
return this.active && !this.root;
137+
}
138+
134139
ngOnDestroy() {
135140
if (this.menuSourceSubscription) {
136141
this.menuSourceSubscription.unsubscribe();

0 commit comments

Comments
 (0)