Skip to content

Commit 5247280

Browse files
authored
fix(tooltip): use inject document for ssr - 19.2.x (#15952)
1 parent becbd2e commit 5247280

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

projects/igniteui-angular/src/lib/directives/tooltip/tooltip.directive.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { DOCUMENT } from '@angular/common';
12
import {
2-
Directive, ElementRef, Input, ChangeDetectorRef, Optional, HostBinding, Inject, OnDestroy
3+
Directive, ElementRef, Input, ChangeDetectorRef, Optional, HostBinding, Inject, OnDestroy, inject
34
} from '@angular/core';
45
import { IgxOverlayService } from '../../services/overlay/overlay';
56
import { OverlaySettings } from '../../services/public_api';
@@ -110,6 +111,7 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy
110111
public tooltipTarget: IgxTooltipTargetDirective;
111112

112113
private _destroy$ = new Subject<boolean>();
114+
private _document = inject(DOCUMENT);
113115

114116
/** @hidden */
115117
constructor(
@@ -122,18 +124,18 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy
122124

123125
this.onDocumentTouchStart = this.onDocumentTouchStart.bind(this);
124126
this.overlayService.opening.pipe(takeUntil(this._destroy$)).subscribe(() => {
125-
document.addEventListener('touchstart', this.onDocumentTouchStart, { passive: true });
127+
this._document.addEventListener('touchstart', this.onDocumentTouchStart, { passive: true });
126128
});
127129
this.overlayService.closed.pipe(takeUntil(this._destroy$)).subscribe(() => {
128-
document.removeEventListener('touchstart', this.onDocumentTouchStart);
130+
this._document.removeEventListener('touchstart', this.onDocumentTouchStart);
129131
});
130132
}
131133

132134
/** @hidden */
133135
public override ngOnDestroy() {
134136
super.ngOnDestroy();
135137

136-
document.removeEventListener('touchstart', this.onDocumentTouchStart);
138+
this._document.removeEventListener('touchstart', this.onDocumentTouchStart);
137139
this._destroy$.next(true);
138140
this._destroy$.complete();
139141
}

0 commit comments

Comments
 (0)