File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ export const Tooltip = ({
6464 const placeholderRef = React . useRef ( null ) ;
6565 const eventMemory = React . useRef < null | "afterhover" | "afterfocus" > ( null ) ;
6666 const searchId = React . useRef < null | string > ( null ) ;
67+ const swapDelay = React . useRef < null | NodeJS . Timeout > ( null ) ;
6768 const swapDelayTime = swapPlaceholderDelay ;
6869 const [ placeholder , setPlaceholder ] = React . useState < boolean > (
6970 ! otherTooltipProps . disabled &&
@@ -83,7 +84,10 @@ export const Tooltip = ({
8384 React . useEffect ( ( ) => {
8485 if ( placeholderRef . current !== null ) {
8586 const swap = ( ev : MouseEvent | globalThis . FocusEvent ) => {
86- const swapDelay = setTimeout ( ( ) => {
87+ if ( swapDelay . current ) {
88+ clearTimeout ( swapDelay . current ) ;
89+ }
90+ swapDelay . current = setTimeout ( ( ) => {
8791 // we delay the swap to prevent unwanted effects
8892 // (e.g. forced mouseover after the swap but the cursor is already somewhere else)
8993 eventMemory . current = ev . type === "focusin" ? "afterfocus" : "afterhover" ;
@@ -99,7 +103,7 @@ export const Tooltip = ({
99103 ) {
100104 eventMemory . current = null ;
101105 }
102- clearTimeout ( swapDelay ) ;
106+ clearTimeout ( swapDelay . current as NodeJS . Timeout ) ;
103107 } ) ;
104108 }
105109 } ;
You can’t perform that action at this time.
0 commit comments