From d5db6c3af7ab5645a06ab9a849f28bd43345b5f2 Mon Sep 17 00:00:00 2001 From: Daniel Hoe Date: Tue, 3 Aug 2021 17:08:54 +0800 Subject: [PATCH] Fix bug where clicking on "home" in batches causes sidebar to switch --- .../navigation/nav-controller/nav-controller.component.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/navigation/nav-controller/nav-controller.component.ts b/src/app/navigation/nav-controller/nav-controller.component.ts index 83f7d54..9f3d2ea 100644 --- a/src/app/navigation/nav-controller/nav-controller.component.ts +++ b/src/app/navigation/nav-controller/nav-controller.component.ts @@ -41,7 +41,6 @@ export class NavControllerComponent implements OnInit { this.router.events.subscribe((val) => { if (val instanceof NavigationEnd) { this.loadingService.setLoading(true); - console.log(val); this.navControllerService.onRouteUpdate(val); this.navigateToLink(val.url); } @@ -94,7 +93,9 @@ export class NavControllerComponent implements OnInit { pages = ['home', 'about', 'batches', 'sov', 'listen', 'contribute', 'misc'] navigateToLink(url: string) { for(let i = 0; i < this.pages.length; i ++) { - if(url.toLowerCase().includes(this.pages[i])) { + let sourceUrl = url.split("#")[0]; + + if(sourceUrl.toLowerCase().includes(this.pages[i])) { let temp = this.menu.filter(x => x.linkName.includes(this.pages[i])); this.navigateTo(temp[0]); return;