@@ -45,19 +45,33 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
45
45
// ========================== Register ==========================
46
46
const [ popupId , setPopupId ] = React . useState ( 0 ) ;
47
47
48
+ // Store the isOpen function from the latest show call
49
+ const isOpenRef = React . useRef < ( ( ) => boolean ) | null > ( null ) ;
50
+
48
51
const delayInvoke = useDelay ( ) ;
49
52
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
+ ) ;
58
66
59
67
const hide = ( delay : number ) => {
60
68
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
+
61
75
trigger ( false ) ;
62
76
// Don't clear target, currentNode, options immediately, wait until animation completes
63
77
} , delay ) ;
@@ -106,7 +120,10 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
106
120
false , // alignPoint is false for UniqueProvider
107
121
) ;
108
122
109
- return classNames ( baseClassName , options . getPopupClassNameFromAlign ?.( alignInfo ) ) ;
123
+ return classNames (
124
+ baseClassName ,
125
+ options . getPopupClassNameFromAlign ?.( alignInfo ) ,
126
+ ) ;
110
127
} , [
111
128
alignInfo ,
112
129
options ?. getPopupClassNameFromAlign ,
0 commit comments