@@ -45,19 +45,33 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
4545  // ========================== Register ========================== 
4646  const  [ popupId ,  setPopupId ]  =  React . useState ( 0 ) ; 
4747
48+   // Store the isOpen function from the latest show call 
49+   const  isOpenRef  =  React . useRef < ( ( )  =>  boolean )  |  null > ( null ) ; 
50+ 
4851  const  delayInvoke  =  useDelay ( ) ; 
4952
50-   const  show  =  useEvent ( ( showOptions : UniqueShowOptions )  =>  { 
51-     delayInvoke ( ( )  =>  { 
52-       if  ( showOptions . id  !==  options ?. id )  { 
53-         setPopupId ( ( i )  =>  i  +  1 ) ; 
54-       } 
55-       trigger ( showOptions ) ; 
56-     } ,  showOptions . delay ) ; 
57-   } ) ; 
53+   const  show  =  useEvent ( 
54+     ( showOptions : UniqueShowOptions ,  isOpen : ( )  =>  boolean )  =>  { 
55+       // Store the isOpen function for later use in hide 
56+       isOpenRef . current  =  isOpen ; 
57+ 
58+       delayInvoke ( ( )  =>  { 
59+         if  ( showOptions . id  !==  options ?. id )  { 
60+           setPopupId ( ( i )  =>  i  +  1 ) ; 
61+         } 
62+         trigger ( showOptions ) ; 
63+       } ,  showOptions . delay ) ; 
64+     } , 
65+   ) ; 
5866
5967  const  hide  =  ( delay : number )  =>  { 
6068    delayInvoke ( ( )  =>  { 
69+       // Check if we should still hide by calling the isOpen function 
70+       // If isOpen returns true, it means another trigger wants to keep it open 
71+       if  ( isOpenRef . current ?.( ) )  { 
72+         return ;  // Don't hide if something else wants it open 
73+       } 
74+ 
6175      trigger ( false ) ; 
6276      // Don't clear target, currentNode, options immediately, wait until animation completes 
6377    } ,  delay ) ; 
@@ -106,7 +120,10 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
106120      false ,  // alignPoint is false for UniqueProvider 
107121    ) ; 
108122
109-     return  classNames ( baseClassName ,  options . getPopupClassNameFromAlign ?.( alignInfo ) ) ; 
123+     return  classNames ( 
124+       baseClassName , 
125+       options . getPopupClassNameFromAlign ?.( alignInfo ) , 
126+     ) ; 
110127  } ,  [ 
111128    alignInfo , 
112129    options ?. getPopupClassNameFromAlign , 
0 commit comments