Skip to content

Commit

Permalink
Fix toggle issues in sidenav (pinning and on page refresh)
Browse files Browse the repository at this point in the history
  • Loading branch information
lacksfish committed Dec 6, 2023
1 parent 9992044 commit fc0409c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
<rtl-top-menu />
</div>
</mat-toolbar>
<mat-sidenav-container>
<mat-sidenav-container (backdropClick)="backdropClicked()">
<mat-sidenav #sideNavigation class="sidenav mat-elevation-z6" [perfectScrollbar] [opened]="flgSideNavOpened && flgLoggedIn" [mode]="(flgSidenavPinned && !smallScreen) ? 'side' : 'over'">
<rtl-side-navigation fxFlex="100" (ChildNavClicked)="onNavigationClicked($event)" />
</mat-sidenav>
<mat-sidenav-content #sideNavContent [perfectScrollbar]>
<div class="inner-sidenav-content" fxLayout="column" fxFlex="100" fxLayoutAlign="start stretch">
<router-outlet #outlet="outlet" />
</div>
</mat-sidenav-content>>
</mat-sidenav-content>
</mat-sidenav-container>
<div *ngIf="!settings.themeColor" class="rtl-spinner">
<mat-spinner color="accent" />
Expand Down
13 changes: 12 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
}

ngAfterViewInit() {
if (this.smallScreen || !this.flgLoggedIn) { this.sideNavigation.close(); }
if (this.smallScreen || !this.flgLoggedIn) {
this.flgSideNavOpened = !this.flgSideNavOpened;
this.sideNavigation.close();
}
this.commonService.setContainerSize(this.sideNavContent.elementRef.nativeElement.clientWidth, this.sideNavContent.elementRef.nativeElement.clientHeight);
}

Expand All @@ -170,6 +173,14 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {

onNavigationClicked(event: any) {
if (this.smallScreen) {
this.flgSideNavOpened = !this.flgSideNavOpened;
this.sideNavigation.close();
}
}

backdropClicked() {
if (!this.flgSidenavPinned || this.smallScreen) {
this.flgSideNavOpened = !this.flgSideNavOpened;
this.sideNavigation.close();
}
}
Expand Down

0 comments on commit fc0409c

Please sign in to comment.