Skip to content

Commit ef8c56a

Browse files
committed
fix: on this page anchors clickable again
1 parent b31d0f6 commit ef8c56a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/components/layout/content/content.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</div>
5757
<a
5858
*ngFor="let pageAnchor of pageAnchors; trackBy: trackBy"
59-
[routerLink]=""
59+
[routerLink]="currentUrl$ | async"
6060
[replaceUrl]="true"
6161
[fragment]="pageAnchor.id"
6262
[style.padding-left]="pageAnchor.indent * 8"

src/components/layout/content/content.component.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import {
99
ElementRef,
1010
ChangeDetectorRef,
1111
TrackByFunction,
12-
HostListener,
1312
OnDestroy,
1413
} from '@angular/core';
15-
import {ActivatedRoute, RouterLink} from '@angular/router';
16-
import {NgIf, NgFor} from '@angular/common';
14+
import {ActivatedRoute, RouterLink, UrlSegment} from '@angular/router';
15+
import {NgIf, NgFor, AsyncPipe} from '@angular/common';
1716
import {CdkObserveContent} from '@angular/cdk/observers';
17+
import {Observable} from 'rxjs';
1818

1919
export interface ContentPageAnchor {
2020
id: string;
@@ -65,7 +65,7 @@ function getAnchorTitleText(element: Element): string {
6565
styleUrls: ['./content.component.scss'],
6666
changeDetection: ChangeDetectionStrategy.OnPush,
6767
standalone: true,
68-
imports: [CdkObserveContent, NgIf, RouterLink, NgFor],
68+
imports: [CdkObserveContent, NgIf, RouterLink, NgFor, AsyncPipe],
6969
})
7070
export class ContentComponent implements OnInit, OnDestroy {
7171
private _anchorEventListenerCleanupFns: (() => void)[] = [];
@@ -77,6 +77,7 @@ export class ContentComponent implements OnInit, OnDestroy {
7777
@ViewChild('mainContent', {static: true})
7878
mainContent?: ElementRef<HTMLElement>;
7979

80+
readonly currentUrl$: Observable<UrlSegment[]>;
8081
readonly trackBy: TrackByFunction<ContentPageAnchor>;
8182
readonly canShare = (window as any).navigator.canShare
8283
? (window as any).navigator.canShare({url: window.location.href})
@@ -87,6 +88,7 @@ export class ContentComponent implements OnInit, OnDestroy {
8788
private cdr: ChangeDetectorRef,
8889
route: ActivatedRoute,
8990
) {
91+
this.currentUrl$ = route.url;
9092
this.trackBy = (index, item) => {
9193
return item.id;
9294
};

0 commit comments

Comments
 (0)