11import {
22 Directive , ElementRef , Input , ChangeDetectorRef , Optional , HostBinding , Inject ,
33 OnDestroy , inject , DOCUMENT , HostListener ,
4+ Renderer2 ,
5+ AfterViewInit ,
46} from '@angular/core' ;
57import { IgxOverlayService } from '../../services/overlay/overlay' ;
68import { IgxNavigationService } from '../../core/navigation' ;
79import { IgxToggleDirective } from '../toggle/toggle.directive' ;
810import { IgxTooltipTargetDirective } from './tooltip-target.directive' ;
911import { Subject , takeUntil } from 'rxjs' ;
12+ import { PlatformUtil } from '../../core/utils' ;
1013
1114let NEXT_ID = 0 ;
1215/**
@@ -28,7 +31,7 @@ let NEXT_ID = 0;
2831 selector : '[igxTooltip]' ,
2932 standalone : true
3033} )
31- export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy {
34+ export class IgxTooltipDirective extends IgxToggleDirective implements AfterViewInit , OnDestroy {
3235 /**
3336 * @hidden
3437 */
@@ -116,6 +119,8 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy
116119 private _role : 'tooltip' | 'status' = 'tooltip' ;
117120 private _destroy$ = new Subject < boolean > ( ) ;
118121 private _document = inject ( DOCUMENT ) ;
122+ private _renderer = inject ( Renderer2 ) ;
123+ private _platformUtil = inject ( PlatformUtil ) ;
119124
120125 /** @hidden */
121126 constructor (
@@ -133,8 +138,13 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy
133138 this . closed . pipe ( takeUntil ( this . _destroy$ ) ) . subscribe ( ( ) => {
134139 this . _document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
135140 } ) ;
141+ }
136142
137- this . _createArrow ( ) ;
143+ /** @hidden */
144+ public ngAfterViewInit ( ) : void {
145+ if ( this . _platformUtil . isBrowser ) {
146+ this . _createArrow ( ) ;
147+ }
138148 }
139149
140150 /** @hidden */
@@ -144,7 +154,10 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy
144154 this . _document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
145155 this . _destroy$ . next ( true ) ;
146156 this . _destroy$ . complete ( ) ;
147- this . _removeArrow ( ) ;
157+
158+ if ( this . arrow ) {
159+ this . _removeArrow ( ) ;
160+ }
148161 }
149162
150163 /**
@@ -192,10 +205,10 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy
192205 }
193206
194207 private _createArrow ( ) : void {
195- this . _arrowEl = document . createElement ( 'span' ) ;
196- this . _arrowEl . style . position = 'absolute' ;
197- this . _arrowEl . setAttribute ( 'data-arrow' , 'true' ) ;
198- this . element . appendChild ( this . _arrowEl ) ;
208+ this . _arrowEl = this . _renderer . createElement ( 'span' ) ;
209+ this . _renderer . setStyle ( this . _arrowEl , ' position' , 'absolute' ) ;
210+ this . _renderer . setAttribute ( this . _arrowEl , 'data-arrow' , 'true' ) ;
211+ this . _renderer . appendChild ( this . element , this . _arrowEl ) ;
199212 }
200213
201214 private _removeArrow ( ) : void {
0 commit comments