Skip to content

Commit

Permalink
fix: dialog reappear after closed
Browse files Browse the repository at this point in the history
  • Loading branch information
vuhuucuong committed Dec 24, 2022
1 parent 56a414f commit 39b7801
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Dialog/Content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
contentStyle.transformOrigin = transformOrigin;
}

function onPrepare() {
function onPrepare(dialog) {
dialog.style.display = null;
const elementOffset = offset(dialogRef.current);

setTransformOrigin(
Expand All @@ -47,6 +48,10 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
);
}

function onLeave(dialog) {
dialog.style.display = 'none';
}

// ============================= Render =============================
return (
<CSSMotion
Expand All @@ -57,6 +62,7 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
forceRender={forceRender}
motionName={motionName}
removeOnLeave={destroyOnClose}
onLeaveEnd={onLeave}
ref={dialogRef}
>
{({ className: motionClassName, style: motionStyle }, motionRef) => (
Expand Down

0 comments on commit 39b7801

Please sign in to comment.