Skip to content

Commit

Permalink
refactor(devtools): fix issue with virtual scroll viewport in the dir…
Browse files Browse the repository at this point in the history
…ective forest (#54912)

In some cases the height of the viewport wasn't calculated correctly because of extension tabs quirks. This commit fixes this issue.

Fixes #53704

PR Close #54912
  • Loading branch information
JeanMeche authored and AndrewKushnir committed Apr 25, 2024
1 parent 9ec0136 commit 621f598
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ElementRef,
EventEmitter,
HostListener,
Input,
Expand Down Expand Up @@ -99,11 +100,13 @@ export class DirectiveForestComponent {
readonly itemHeight = 18;

private _initialized = false;
private resizeObserver: ResizeObserver;

constructor(
private _tabUpdate: TabUpdate,
private _messageBus: MessageBus<Events>,
private _cdr: ChangeDetectorRef,
private elementRef: ElementRef,
) {
this.subscribeToInspectorEvents();
this._tabUpdate.tabUpdate$.pipe(takeUntilDestroyed()).subscribe(() => {
Expand All @@ -114,6 +117,17 @@ export class DirectiveForestComponent {
});
}
});

// In some cases there a height changes, we need to recalculate the viewport size.
this.resizeObserver = new ResizeObserver(() => {
this.viewport.scrollToIndex(0);
this.viewport.checkViewportSize();
});
this.resizeObserver.observe(this.elementRef.nativeElement);
}

ngOnDestroy(): void {
this.resizeObserver.disconnect();
}

subscribeToInspectorEvents(): void {
Expand Down

0 comments on commit 621f598

Please sign in to comment.