From 8ebc98587f8b1d9b261b1157be93f5adf047d697 Mon Sep 17 00:00:00 2001 From: RivaIvanova Date: Wed, 18 Jun 2025 09:10:31 +0300 Subject: [PATCH] fix(tooltip): use inject document for ssr --- .../src/lib/directives/tooltip/tooltip.directive.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/igniteui-angular/src/lib/directives/tooltip/tooltip.directive.ts b/projects/igniteui-angular/src/lib/directives/tooltip/tooltip.directive.ts index e89a280614c..e03128ec49c 100644 --- a/projects/igniteui-angular/src/lib/directives/tooltip/tooltip.directive.ts +++ b/projects/igniteui-angular/src/lib/directives/tooltip/tooltip.directive.ts @@ -1,5 +1,5 @@ import { - Directive, ElementRef, Input, ChangeDetectorRef, Optional, HostBinding, Inject, OnDestroy + Directive, ElementRef, Input, ChangeDetectorRef, Optional, HostBinding, Inject, OnDestroy, inject, DOCUMENT } from '@angular/core'; import { IgxOverlayService } from '../../services/overlay/overlay'; import { OverlaySettings } from '../../services/public_api'; @@ -110,6 +110,7 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy public tooltipTarget: IgxTooltipTargetDirective; private _destroy$ = new Subject(); + private _document = inject(DOCUMENT); /** @hidden */ constructor( @@ -122,10 +123,10 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy this.onDocumentTouchStart = this.onDocumentTouchStart.bind(this); this.overlayService.opening.pipe(takeUntil(this._destroy$)).subscribe(() => { - document.addEventListener('touchstart', this.onDocumentTouchStart, { passive: true }); + this._document.addEventListener('touchstart', this.onDocumentTouchStart, { passive: true }); }); this.overlayService.closed.pipe(takeUntil(this._destroy$)).subscribe(() => { - document.removeEventListener('touchstart', this.onDocumentTouchStart); + this._document.removeEventListener('touchstart', this.onDocumentTouchStart); }); } @@ -133,7 +134,7 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy public override ngOnDestroy() { super.ngOnDestroy(); - document.removeEventListener('touchstart', this.onDocumentTouchStart); + this._document.removeEventListener('touchstart', this.onDocumentTouchStart); this._destroy$.next(true); this._destroy$.complete(); }