@@ -42,6 +42,8 @@ export class PopoverDirective implements OnDestroy, OnInit, AfterViewInit {
4242 readonly #intersectionService = inject ( IntersectionService ) ;
4343 readonly #destroyRef = inject ( DestroyRef ) ;
4444 readonly #document = inject ( DOCUMENT ) ;
45+ #timerId1: ReturnType < typeof setTimeout > | undefined ;
46+ #timerId2: ReturnType < typeof setTimeout > | undefined ;
4547
4648 /**
4749 * Content of popover
@@ -234,26 +236,34 @@ export class PopoverDirective implements OnDestroy, OnInit, AfterViewInit {
234236 this . removeTooltipElement ( ) ;
235237 return ;
236238 }
237- setTimeout ( ( ) => {
239+
240+ clearTimeout ( this . #timerId2) ;
241+ clearTimeout ( this . #timerId1) ;
242+ this . #timerId1 = setTimeout ( ( ) => {
238243 this . tooltipId = this . getUID ( 'popover' ) ;
239244 this . tooltipRef ?. setInput ( 'id' , this . tooltipId ) ;
240245 this . #renderer. removeClass ( this . tooltip , 'd-none' ) ;
241246 this . tooltipRef ?. setInput ( 'visible' , this . visible ( ) ) ;
242247 this . popperInstance ?. forceUpdate ( ) ;
243248 this . #changeDetectorRef?. markForCheck ( ) ;
244- } , 100 ) ;
249+ this . #timerId1 = undefined ;
250+ } , 150 ) ;
245251 }
246252
247253 private removeTooltipElement ( ) : void {
248254 this . tooltipId = '' ;
249255 if ( ! this . tooltipRef ) {
250256 return ;
251257 }
258+
259+ clearTimeout ( this . #timerId2) ;
260+ this . #timerId2 = setTimeout ( ( ) => {
261+ this . #viewContainerRef?. detach ( ) ;
262+ this . #timerId2 = undefined ;
263+ } , 300 ) ;
264+
252265 this . tooltipRef . setInput ( 'visible' , false ) ;
253266 this . tooltipRef . setInput ( 'id' , undefined ) ;
254267 this . #changeDetectorRef. markForCheck ( ) ;
255- setTimeout ( ( ) => {
256- this . #viewContainerRef?. detach ( ) ;
257- } , 300 ) ;
258268 }
259269}
0 commit comments