Skip to content

Commit

Permalink
fix(tooltip): prevent infinite loop error when positioning tooltip
Browse files Browse the repository at this point in the history
Fixes #1046
  • Loading branch information
mattlewis92 committed Aug 18, 2019
1 parent ca3220b commit cd2cd5a
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class CalendarTooltipDirective implements OnDestroy, OnChanges {
this.cancelTooltipDelay$.next();
}

private positionTooltip(previousPosition?: string): void {
private positionTooltip(previousPositions: string[] = []): void {
if (this.tooltipRef) {
this.tooltipRef.changeDetectorRef.detectChanges();
this.tooltipRef.instance.placement = positionElements(
Expand All @@ -160,8 +160,13 @@ export class CalendarTooltipDirective implements OnDestroy, OnChanges {
this.appendToBody
);
// keep re-positioning the tooltip until the arrow position doesn't make a difference
if (previousPosition !== this.tooltipRef.instance.placement) {
this.positionTooltip(this.tooltipRef.instance.placement);
if (
previousPositions.indexOf(this.tooltipRef.instance.placement) === -1
) {
this.positionTooltip([
...previousPositions,
this.tooltipRef.instance.placement
]);
}
}
}
Expand Down

0 comments on commit cd2cd5a

Please sign in to comment.