Skip to content

Commit

Permalink
Fix tab change & reload page issue
Browse files Browse the repository at this point in the history
  • Loading branch information
oye816 committed May 7, 2024
1 parent 4d840b5 commit a3f8773
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,24 @@ export abstract class CrisLayoutTabsComponent {
const itemPageRoute = getItemPageRoute(this.item);
this.activeTab$.next(tab);
this.emitSelected(tab);

let queryParams = {};

this.route.queryParams.subscribe(params => {
queryParams = params;
});

const currentTabName = this.route.snapshot.paramMap.get('tab');
const navigationExtras = (currentTabName && currentTabName.includes(tab.shortname)) ? { queryParams: queryParams } : {};

let newUrl: string;
if (this.tabs[0].shortname === tab.shortname) {
this.location.replaceState(itemPageRoute);
newUrl = itemPageRoute;
} else {
this.location.replaceState(itemPageRoute + '/' + tab.shortname);
newUrl = itemPageRoute + '/' + tab.shortname;
}

this.router.navigate([newUrl], navigationExtras);
}

}

0 comments on commit a3f8773

Please sign in to comment.