11import {
2- Directive , ElementRef , Input , ChangeDetectorRef , Optional , HostBinding , Inject , OnDestroy
2+ Directive , ElementRef , Input , ChangeDetectorRef , Optional , HostBinding , Inject , OnDestroy , inject , DOCUMENT
33} from '@angular/core' ;
44import { IgxOverlayService } from '../../services/overlay/overlay' ;
55import { OverlaySettings } from '../../services/public_api' ;
@@ -110,6 +110,7 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy
110110 public tooltipTarget : IgxTooltipTargetDirective ;
111111
112112 private _destroy$ = new Subject < boolean > ( ) ;
113+ private _document = inject ( DOCUMENT ) ;
113114
114115 /** @hidden */
115116 constructor (
@@ -122,18 +123,18 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy
122123
123124 this . onDocumentTouchStart = this . onDocumentTouchStart . bind ( this ) ;
124125 this . overlayService . opening . pipe ( takeUntil ( this . _destroy$ ) ) . subscribe ( ( ) => {
125- document . addEventListener ( 'touchstart' , this . onDocumentTouchStart , { passive : true } ) ;
126+ this . _document . addEventListener ( 'touchstart' , this . onDocumentTouchStart , { passive : true } ) ;
126127 } ) ;
127128 this . overlayService . closed . pipe ( takeUntil ( this . _destroy$ ) ) . subscribe ( ( ) => {
128- document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
129+ this . _document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
129130 } ) ;
130131 }
131132
132133 /** @hidden */
133134 public override ngOnDestroy ( ) {
134135 super . ngOnDestroy ( ) ;
135136
136- document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
137+ this . _document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
137138 this . _destroy$ . next ( true ) ;
138139 this . _destroy$ . complete ( ) ;
139140 }
0 commit comments