Skip to content

Commit

Permalink
fix(module:tooltip): fix tooltip accessing destroyed view
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell committed Nov 5, 2019
1 parent cc3868e commit 616f67f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions components/tooltip/base/nz-tooltip-base.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ export abstract class NzTooltipBaseDirective implements OnChanges, OnInit, OnDes
ngOnDestroy(): void {
this.$destroy.next();
this.$destroy.complete();

// Clear toggling timer. Issue #3875 #4317 #4386
this.hide();
this.clearTogglingTimer();

if (this.tooltipRef) {
this.tooltipRef.destroy();
}
Expand Down Expand Up @@ -327,10 +332,9 @@ export abstract class NzTooltipBaseDirective implements OnChanges, OnInit, OnDes
}

private delayEnterLeave(isOrigin: boolean, isEnter: boolean, delay: number = -1): void {
if (this.delayTimer) {
clearTimeout(this.delayTimer);
this.delayTimer = undefined;
} else if (delay > 0) {
this.clearTogglingTimer();

if (delay > 0) {
this.delayTimer = setTimeout(() => {
this.delayTimer = undefined;
isEnter ? this.show() : this.hide();
Expand All @@ -341,4 +345,11 @@ export abstract class NzTooltipBaseDirective implements OnChanges, OnInit, OnDes
isEnter && isOrigin ? this.show() : this.hide();
}
}

private clearTogglingTimer(): void {
if (this.delayTimer) {
clearTimeout(this.delayTimer);
this.delayTimer = undefined;
}
}
}

0 comments on commit 616f67f

Please sign in to comment.