mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-19 16:03:02 +00:00
[DURACOM-191] Fix selected tab for the comcol-page-browse-by.component
This commit is contained in:
@@ -25,7 +25,10 @@ import {
|
||||
Subscription,
|
||||
} from 'rxjs';
|
||||
import {
|
||||
distinctUntilChanged,
|
||||
filter,
|
||||
map,
|
||||
startWith,
|
||||
take,
|
||||
} from 'rxjs/operators';
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
Reference in New Issue
Block a user