Skip to content

Commit d448ab8

Browse files
fix: modal animation (#1018)
1 parent 4bd21b5 commit d448ab8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/kit-headless/src/components/modal/modal-panel.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,26 @@ export const HModalPanel = component$((props: PropsOf<'dialog'>) => {
5353

5454
await showModal(panelRef.value);
5555
window.requestAnimationFrame = storedRequestAnimationFrame;
56-
await context.onShow$?.();
5756
activateFocusTrap(focusTrap);
5857
} else {
5958
await closeModal(panelRef.value);
60-
await context.onClose$?.();
6159
}
6260

6361
cleanup(async () => {
6462
await deactivateFocusTrap(focusTrap);
6563
});
6664
});
6765

66+
useTask$(async ({ track }) => {
67+
track(() => context.showSig.value);
68+
69+
if (context.showSig.value) {
70+
await context.onShow$?.();
71+
} else {
72+
await context.onClose$?.();
73+
}
74+
});
75+
6876
const closeOnBackdropClick$ = $(async (e: MouseEvent) => {
6977
if (context.alert === true || context.closeOnBackdropClick === false) {
7078
return;

0 commit comments

Comments
 (0)