File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
packages/react/src/TooltipV2 Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -213,6 +213,8 @@ export const Tooltip = React.forwardRef(
213213
214214 const [ isPopoverOpen , setIsPopoverOpen ] = useState ( false )
215215
216+ const [ timeoutId , setTimeoutId ] = useState < NodeJS . Timeout | null > ( null )
217+
216218 const openTooltip = ( ) => {
217219 try {
218220 if (
@@ -362,10 +364,19 @@ export const Tooltip = React.forwardRef(
362364 child . props . onFocus ?.( event )
363365 } ,
364366 onMouseEnter : ( event : React . MouseEvent ) => {
365- openTooltip ( )
366- child . props . onMouseEnter ?.( event )
367+ // show tooltip after mosue has been hovering for at least 50ms
368+ // (prevent showing tooltip when mouse is just passing through)
369+ const timeoutId = setTimeout ( ( ) => {
370+ openTooltip ( )
371+ child . props . onMouseEnter ?.( event )
372+ } , 50 )
373+
374+ setTimeoutId ( timeoutId )
367375 } ,
368376 onMouseLeave : ( event : React . MouseEvent ) => {
377+ if ( timeoutId ) {
378+ clearTimeout ( timeoutId )
379+ }
369380 closeTooltip ( )
370381 child . props . onMouseLeave ?.( event )
371382 } ,
You can’t perform that action at this time.
0 commit comments