Check the full URL rather than only the collection id to detect the default path

This commit is contained in:
Abel Gómez
2025-03-14 01:01:52 +01:00
parent 30b411285c
commit 422a714935

View File

@@ -131,6 +131,13 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
}), }),
); );
let comColRoute: string;
if (this.contentType === 'collection') {
comColRoute = getCollectionPageRoute(this.id);
} else if (this.contentType === 'community') {
comColRoute = getCommunityPageRoute(this.id);
}
this.subs.push(combineLatest([ this.subs.push(combineLatest([
this.allOptions$, this.allOptions$,
this.router.events.pipe( this.router.events.pipe(
@@ -141,15 +148,17 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {
), ),
]).subscribe(([navOptions, url]: [ComColPageNavOption[], string]) => { ]).subscribe(([navOptions, url]: [ComColPageNavOption[], string]) => {
for (const option of navOptions) { for (const option of navOptions) {
if (url?.split('?')[0].endsWith(`/${this.id}`) && option.id === this.appConfig[this.contentType].defaultBrowseTab) { if (url?.split('?')[0] === comColRoute && option.id === this.appConfig[this.contentType].defaultBrowseTab) {
void this.router.navigate([option.routerLink], { queryParams: option.params }); void this.router.navigate([option.routerLink], { queryParams: option.params });
break;
} else if (option.routerLink === url?.split('?')[0]) { } else if (option.routerLink === url?.split('?')[0]) {
this.currentOption$.next(option); this.currentOption$.next(option);
break;
} }
} }
})); }));
if (this.router.url?.split('?')[0].endsWith(`/${this.id}`)) { if (this.router.url?.split('?')[0] === comColRoute) {
this.allOptions$.pipe( this.allOptions$.pipe(
take(1), take(1),
).subscribe((allOptions: ComColPageNavOption[]) => { ).subscribe((allOptions: ComColPageNavOption[]) => {