Skip to content

Commit

Permalink
fix(core): remove redundant api calls in dynamic page
Browse files Browse the repository at this point in the history
  • Loading branch information
CSEHoangV committed Oct 6, 2024
1 parent 104e1f5 commit 5be7a06
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libs/core/tabs/tab-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { ScrollSpyDirective } from '@fundamental-ngx/core/scroll-spy';
import { ScrollbarDirective } from '@fundamental-ngx/core/scrollbar';
import { FD_TABLIST, TabList } from '@fundamental-ngx/core/shared';
import { Observable, Subject, Subscription, fromEvent, merge } from 'rxjs';
import { debounceTime, delay, filter, first, map, startWith, switchMap, tap } from 'rxjs/operators';
import { debounceTime, delay, filter, first, map, startWith, switchMap, take, tap } from 'rxjs/operators';
import { TabItemExpandComponent } from './tab-item-expand/tab-item-expand.component';
import { TabItemDirective } from './tab-item/tab-item.directive';
import { TabLinkDirective } from './tab-link/tab-link.directive';
Expand Down Expand Up @@ -235,6 +235,9 @@ export class TabListComponent
/** @hidden */
_init = true;

/** @hidden */
_currentNumberOfTabs = 0;

/** Scrollable element reference. */
get scrollableElement(): Nullable<ElementRef> {
return this._scrollbar?.elementRef;
Expand Down Expand Up @@ -378,7 +381,12 @@ export class TabListComponent
takeUntilDestroyed(this._destroyRef)
)
.subscribe(() => {
this.stackContent && this._scrollSpy?.onScroll(undefined, true);
if (this.stackContent && this._currentNumberOfTabs !== this._tabArray.length) {
this._zone.onMicrotaskEmpty.pipe(take(1)).subscribe(() => {
this._scrollSpy?.onScroll(undefined, true);
this._currentNumberOfTabs = this._tabArray.length;
});
}
});
}

Expand Down

0 comments on commit 5be7a06

Please sign in to comment.