@@ -82,24 +82,6 @@ const Tooltip = ({
8282 }
8383 } , [ ] )
8484
85- useEffect ( ( ) => {
86- if ( ! show ) {
87- /**
88- * this fixes weird behavior when switching between two anchor elements very quickly
89- * remove the timeout and switch quickly between two adjancent anchor elements to see it
90- *
91- * in practice, this means the tooltip is not immediately removed from the DOM on hide
92- */
93- const timeout = setTimeout ( ( ) => {
94- setRendered ( false )
95- } , 150 )
96- return ( ) => {
97- clearTimeout ( timeout )
98- }
99- }
100- return ( ) => null
101- } , [ show ] )
102-
10385 const handleShow = ( value : boolean ) => {
10486 if ( ! mounted . current ) {
10587 return
@@ -657,13 +639,21 @@ const Tooltip = ({
657639 styles [ variant ] ,
658640 className ,
659641 `react-tooltip__place-${ actualPlacement } ` ,
660- {
661- 'react-tooltip__show' : canShow ,
662- [ coreStyles [ 'show' ] ] : canShow ,
663- [ coreStyles [ 'fixed' ] ] : positionStrategy === 'fixed' ,
664- [ coreStyles [ 'clickable' ] ] : clickable ,
665- } ,
642+ coreStyles [ canShow ? 'show' : 'closing' ] ,
643+ canShow ? 'react-tooltip__show' : 'react-tooltip__closing' ,
644+ positionStrategy === 'fixed' && coreStyles [ 'fixed' ] ,
645+ clickable && coreStyles [ 'clickable' ] ,
666646 ) }
647+ onTransitionEnd = { ( event : TransitionEvent ) => {
648+ /**
649+ * @warning if `--rt-transition-closing-delay` is set to 0,
650+ * the tooltip will be stuck (but not visible) on the DOM
651+ */
652+ if ( show || event . propertyName !== 'opacity' ) {
653+ return
654+ }
655+ setRendered ( false )
656+ } }
667657 style = { {
668658 ...externalStyles ,
669659 ...inlineStyles ,
@@ -678,13 +668,7 @@ const Tooltip = ({
678668 coreStyles [ 'arrow' ] ,
679669 styles [ 'arrow' ] ,
680670 classNameArrow ,
681- {
682- /**
683- * changed from dash `no-arrow` to camelcase because of:
684- * https://github.com/indooorsman/esbuild-css-modules-plugin/issues/42
685- */
686- [ coreStyles [ 'noArrow' ] ] : noArrow ,
687- } ,
671+ noArrow && coreStyles [ 'noArrow' ] ,
688672 ) }
689673 style = { {
690674 ...inlineArrowStyles ,
0 commit comments