Skip to content

Commit

Permalink
fix(tooltip): fix closing event fire even if tooltip isnt visible #1710
Browse files Browse the repository at this point in the history
  • Loading branch information
Tacho committed Sep 12, 2018
1 parent 2f616e8 commit 9e4da0a
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Directive, ElementRef, HostListener, Input, NgModule, Renderer2, ChangeDetectorRef, OnInit,
Output, EventEmitter, Optional, HostBinding, OnDestroy } from '@angular/core';
import {
Directive, ElementRef, HostListener, Input, NgModule, Renderer2, ChangeDetectorRef, OnInit,
Output, EventEmitter, Optional, HostBinding, OnDestroy
} from '@angular/core';
import { IgxOverlayService } from '../../services/overlay/overlay';
import { HorizontalAlignment, AutoPositionStrategy, PositionSettings } from '../../services';
import { CommonModule } from '@angular/common';
Expand Down Expand Up @@ -80,8 +82,8 @@ export class IgxTooltipActionDirective extends IgxToggleActionDirective implemen
public onTooltipClosed = new EventEmitter<ITooltipClosedEventArgs>();

constructor(private _element: ElementRef,
@Optional() private _navigationService: IgxNavigationService) {
super(_element, _navigationService);
@Optional() private _navigationService: IgxNavigationService) {
super(_element, _navigationService);
}

public ngOnInit() {
Expand Down Expand Up @@ -143,16 +145,19 @@ export class IgxTooltipActionDirective extends IgxToggleActionDirective implemen
}
}

private preMouseLeaveCheck() {
// Return true if the execution in onMouseLeave should be terminated after this method
private preMouseLeaveCheck(): boolean {
clearTimeout(this._timeoutId);

// If tooltip is about to be opened
if (this._toBeShown) {
clearTimeout(this._timeoutId);
this._toBeShown = false;
this._toBeHidden = false;
return;
return true;
}

return false;
}

/* Public Methods */
Expand Down Expand Up @@ -191,8 +196,11 @@ export class IgxTooltipActionDirective extends IgxToggleActionDirective implemen
}

this.checkOutletAndOutsideClick();
this.preMouseLeaveCheck();

const shouldReturn = this.preMouseLeaveCheck();
if (shouldReturn) {
return;
}

const args = { tooltip: this.target, cancel: false };
this.onTooltipClosing.emit(args);

Expand Down

0 comments on commit 9e4da0a

Please sign in to comment.