From d3ac14497d784fda844da062f9919d4391a425d9 Mon Sep 17 00:00:00 2001 From: George Date: Mon, 17 Jul 2023 17:31:12 +0300 Subject: [PATCH] RED-7116, fixed double clicking causing infinite loop. --- .../table-content.component.html | 4 +-- .../table-content/table-content.component.ts | 25 +++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/lib/listing/table-content/table-content.component.html b/src/lib/listing/table-content/table-content.component.html index ea8775c..f8ace0a 100644 --- a/src/lib/listing/table-content/table-content.component.html +++ b/src/lib/listing/table-content/table-content.component.html @@ -17,7 +17,7 @@ [class.help-mode-active]="helpModeService?.isHelpModeActive$ | async" [id]="'item-' + entity.id" [ngClass]="getTableItemClasses(entity)" - [routerLink]="entity.routerLink | tenant" + (click)="initiateNavigation(entity.routerLink)" > , PrimaryK private _lastScrolledIndex = 0; private _multiSelectActive$ = new BehaviorSubject(false); + readonly #navigationEvents = new BehaviorSubject(''); + readonly #tenantsService = inject(TenantsService); + readonly #router = inject(Router); constructor( @Inject(forwardRef(() => ListingComponent)) readonly listingComponent: ListingComponent, @@ -42,6 +48,16 @@ export class TableContentComponent, PrimaryK this.scrollViewport?.checkViewportSize(); }, 0); }); + this.#navigationEvents + .asObservable() + .pipe( + filter(Boolean), + throttleTime(1000), + switchMap(route => this.#router.navigateByUrl(route)), + takeUntilDestroyed(), + ) + // eslint-disable-next-line rxjs/no-ignored-subscription + .subscribe(); } multiSelect(entity: Class, $event: MouseEvent): void { @@ -93,4 +109,9 @@ export class TableContentComponent, PrimaryK private _disableMultiSelect() { this._multiSelectActive$.next(false); } + + initiateNavigation(routerLink: string | undefined) { + if (!routerLink) return; + this.#navigationEvents.next('/' + this.#tenantsService.activeTenantId + routerLink); + } }