Skip to content

Commit

Permalink
[DURACOM-191] Fix selected tab for the comcol-page-browse-by.component
Browse files Browse the repository at this point in the history
  • Loading branch information
atarix83 committed Mar 20, 2024
1 parent bcf8383 commit 8529257
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import {
Subscription,
} from 'rxjs';
import {
distinctUntilChanged,
filter,
map,
startWith,
take,
} from 'rxjs/operators';

Expand All @@ -36,6 +39,7 @@ import { PaginatedList } from '../../../core/data/paginated-list.model';
import { RemoteData } from '../../../core/data/remote-data';
import { BrowseDefinition } from '../../../core/shared/browse-definition.model';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
import { isNotEmpty } from '../../empty.util';

export interface ComColPageNavOption {
id: string;
Expand Down Expand Up @@ -122,13 +126,16 @@ export class ComcolPageBrowseByComponent implements OnDestroy, OnInit {

this.subs.push(combineLatest([
this.allOptions$,
this.router.events,
]).subscribe(([navOptions, scrollEvent]: [ComColPageNavOption[], Scroll]) => {
if (scrollEvent.type === EventType.Scroll) {
for (const option of navOptions) {
if (option.routerLink === scrollEvent.routerEvent.urlAfterRedirects.split('?')[0]) {
this.currentOption$.next(option);
}
this.router.events.pipe(
startWith(this.router),
filter((next: Router|Scroll) => (isNotEmpty((next as Router)?.url) || (next as Scroll)?.type === EventType.Scroll)),
map((next: Router|Scroll) => (next as Router)?.url || (next as Scroll).routerEvent.urlAfterRedirects),
distinctUntilChanged(),
),
]).subscribe(([navOptions, url]: [ComColPageNavOption[], string]) => {
for (const option of navOptions) {
if (option.routerLink === url?.split('?')[0]) {
this.currentOption$.next(option);
}
}
}));
Expand Down

0 comments on commit 8529257

Please sign in to comment.