Skip to content

Commit 7167adc

Browse files
authored
fix(tooltip): use inject document for ssr (#15951)
1 parent cdbc560 commit 7167adc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Directive, ElementRef, Input, ChangeDetectorRef, Optional, HostBinding, Inject, OnDestroy
2+
Directive, ElementRef, Input, ChangeDetectorRef, Optional, HostBinding, Inject, OnDestroy, inject, DOCUMENT
33
} from '@angular/core';
44
import { IgxOverlayService } from '../../services/overlay/overlay';
55
import { 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

Comments
 (0)