File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
projects/igniteui-angular/src/lib/directives/tooltip Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,8 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
211211 return ;
212212 }
213213
214+ this . target . tooltipTarget = this ;
215+
214216 this . checkOutletAndOutsideClick ( ) ;
215217 const shouldReturn = this . preMouseEnterCheck ( ) ;
216218 if ( shouldReturn ) {
@@ -303,6 +305,9 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
303305 this . _overlayDefaults . closeOnEscape = true ;
304306
305307 this . target . closing . pipe ( takeUntil ( this . destroy$ ) ) . subscribe ( ( event ) => {
308+ if ( this . target . tooltipTarget !== this ) {
309+ return ;
310+ }
306311 const hidingArgs = { target : this , tooltip : this . target , cancel : false } ;
307312 this . tooltipHide . emit ( hidingArgs ) ;
308313
@@ -335,6 +340,8 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
335340 public showTooltip ( ) {
336341 clearTimeout ( this . target . timeoutId ) ;
337342
343+ this . target . tooltipTarget = this ;
344+
338345 if ( ! this . target . collapsed ) {
339346 // if close animation has started finish it, or close the tooltip with no animation
340347 this . target . forceClose ( this . mergedOverlaySettings ) ;
Original file line number Diff line number Diff line change @@ -582,6 +582,32 @@ describe('IgxTooltip', () => {
582582 expect ( targetOne . hideTooltip ) . not . toHaveBeenCalled ( ) ;
583583 expect ( targetTwo . hideTooltip ) . toHaveBeenCalledTimes ( 1 ) ;
584584 } ) ) ;
585+
586+ it ( 'should not emit tooltipHide event multiple times' , fakeAsync ( ( ) => {
587+ spyOn ( targetOne . tooltipHide , 'emit' ) ;
588+ spyOn ( targetTwo . tooltipHide , 'emit' ) ;
589+
590+ hoverElement ( buttonOne ) ;
591+ flush ( ) ;
592+
593+ const tooltipHideArgsTargetOne = { target : targetOne , tooltip : fix . componentInstance . tooltip , cancel : false } ;
594+ const tooltipHideArgsTargetTwo = { target : targetTwo , tooltip : fix . componentInstance . tooltip , cancel : false } ;
595+
596+ unhoverElement ( buttonOne ) ;
597+ tick ( 500 ) ;
598+ expect ( targetOne . tooltipHide . emit ) . toHaveBeenCalledOnceWith ( tooltipHideArgsTargetOne ) ;
599+ expect ( targetTwo . tooltipHide . emit ) . not . toHaveBeenCalled ( ) ;
600+ flush ( ) ;
601+
602+ hoverElement ( buttonTwo ) ;
603+ flush ( ) ;
604+
605+ unhoverElement ( buttonTwo ) ;
606+ tick ( 500 ) ;
607+ expect ( targetOne . tooltipHide . emit ) . toHaveBeenCalledOnceWith ( tooltipHideArgsTargetOne ) ;
608+ expect ( targetTwo . tooltipHide . emit ) . toHaveBeenCalledOnceWith ( tooltipHideArgsTargetTwo ) ;
609+ flush ( ) ;
610+ } ) )
585611 } ) ;
586612
587613 describe ( 'Tooltip integration' , ( ) => {
You can’t perform that action at this time.
0 commit comments