Skip to content

Commit 9725906

Browse files
committed
chore: init hooks
1 parent 22d4f01 commit 9725906

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export interface UniqueShowOptions {
3535
}
3636

3737
export interface UniqueContextProps {
38-
show: (options: UniqueShowOptions) => void;
38+
show: (options: UniqueShowOptions, isOpen: () => boolean) => void;
3939
hide: (delay: number) => void;
4040
}
4141

src/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ export function generateTrigger(
309309
}
310310
});
311311

312+
// Support ref
313+
const isOpen = useEvent(() => mergedOpen);
314+
312315
useLayoutEffect(() => {
313316
setInternalOpen(popupVisible || false);
314317
}, [popupVisible]);
@@ -347,9 +350,7 @@ export function generateTrigger(
347350
!parentContext
348351
) {
349352
if (mergedOpen) {
350-
Promise.resolve().then(() => {
351-
uniqueContext.show(getUniqueOptions(0));
352-
});
353+
uniqueContext.show(getUniqueOptions(0), isOpen);
353354
} else {
354355
uniqueContext.hide(0);
355356
}
@@ -395,7 +396,7 @@ export function generateTrigger(
395396
// If there is a parentContext, don't call uniqueContext methods
396397
if (uniqueContext && unique && openUncontrolled && !parentContext) {
397398
if (nextOpen) {
398-
uniqueContext.show(getUniqueOptions(delay));
399+
uniqueContext.show(getUniqueOptions(delay), isOpen);
399400
} else {
400401
uniqueContext.hide(delay);
401402
}

0 commit comments

Comments
 (0)