Skip to content

Commit

Permalink
fix(breadcrumbs): fix rendering issues on load (#2239)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsahitya authored Sep 6, 2024
1 parent e827ffc commit 744f1e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
flex-direction: row;
align-items: center;
align-content: center;
max-width: 100%;
flex-shrink: 0;
justify-content: flex-end;

::ng-deep > * {
Expand Down
14 changes: 13 additions & 1 deletion libs/angular/breadcrumbs/src/breadcrumbs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ElementRef,
Input,
HostBinding,
AfterViewInit,
} from '@angular/core';

import { fromEvent, Subject } from 'rxjs';
Expand All @@ -24,7 +25,7 @@ import { TdBreadcrumbComponent } from './breadcrumb/breadcrumb.component';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TdBreadcrumbsComponent
implements OnInit, AfterContentInit, OnDestroy
implements OnInit, AfterContentInit, AfterViewInit, OnDestroy
{
private _resizing = false;
private _separatorIcon = 'chevron_right';
Expand Down Expand Up @@ -69,12 +70,17 @@ export class TdBreadcrumbsComponent
});
}

ngAfterViewInit(): void {
this._waitToCalculateVisibility();
}

ngAfterContentInit(): void {
// Note: doesn't need to unsubscribe since `QueryList.changes`
// gets completed by Angular when the view is destroyed.
this._breadcrumbs.changes
.pipe(startWith(this._breadcrumbs))
.subscribe(() => {
this._waitToCalculateVisibility();
this.setCrumbIcons();
this._changeDetectorRef.markForCheck();
});
Expand Down Expand Up @@ -156,4 +162,10 @@ export class TdBreadcrumbsComponent
this.hiddenBreadcrumbs = hiddenCrumbs;
this._changeDetectorRef.markForCheck();
}

private _waitToCalculateVisibility(): void {
setTimeout(() => {
this._calculateVisibility();
});
}
}

0 comments on commit 744f1e0

Please sign in to comment.