Skip to content

Commit 262f758

Browse files
committed
Simplify page redirection when the default route is used
1 parent c212b3d commit 262f758

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/app/shared/comcol/comcol-page-browse-by/comcol-page-browse-by.component.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
121121
routerLink: `${comColRoute}/browse/${config.id}`,
122122
})));
123123

124+
// When the default tab is not the "search" tab, the "search" tab is moved
125+
// at the end of the tabs ribbon for aesthetics purposes.
124126
if (this.appConfig[this.contentType].defaultBrowseTab !== 'search') {
125127
allOptions.push(allOptions.shift());
126128
}
@@ -138,17 +140,16 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
138140
distinctUntilChanged(),
139141
),
140142
]).subscribe(([navOptions, url]: [ComColPageNavOption[], string]) => {
141-
if (url?.split('?')[0].endsWith(`/${this.id}`)) {
142-
const option = navOptions.find(o => o.id === this.appConfig[this.contentType].defaultBrowseTab);
143-
void this.router.navigate([option.routerLink], { queryParams: option.params });
144-
} else {
145-
for (const option of navOptions) {
146-
if (option.routerLink === url?.split('?')[0]) {
147-
this.currentOption$.next(option);
148-
}
143+
for (const option of navOptions) {
144+
if (option.routerLink === url?.split('?')[0]) {
145+
this.currentOption$.next(option);
149146
}
150147
}
151148
}));
149+
150+
if (this.router.url?.split('?')[0].endsWith(`/${this.id}`)) {
151+
void this.router.navigate([this.router.url, this.appConfig[this.contentType].defaultBrowseTab]);
152+
}
152153
}
153154

154155
ngOnDestroy(): void {

0 commit comments

Comments
 (0)