Skip to content

Commit

Permalink
fix(spindle-ui): fix close handler to reopen dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
lanberb committed Dec 2, 2022
1 parent debe75a commit d71099a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/spindle-ui/src/Modal/AppealModal.tsx
Expand Up @@ -42,10 +42,13 @@ const Frame = forwardRef<DialogHTMLElement, AppealModalProps>(
onClose && onClose(event);
};

const handleDialogClick = (event: React.MouseEvent<DialogHTMLElement>) => {
// Detect backdrop click
const handleDialogClose = (
event: React.SyntheticEvent<DialogHTMLElement>,
) => {
// Detect backdrop click and EscKey type
if (event.target === dialogEl.current) {
onClose && onClose(event);
setClosing(false);
}
};

Expand All @@ -57,7 +60,6 @@ const Frame = forwardRef<DialogHTMLElement, AppealModalProps>(
!event.pseudoElement // To exclude ::backdrop
) {
dialogEl.current.close && dialogEl.current.close();
setClosing(false);
}
},
[dialogEl],
Expand Down Expand Up @@ -106,7 +108,8 @@ const Frame = forwardRef<DialogHTMLElement, AppealModalProps>(
.join(' ')
.trim()}
ref={mergeRefs([dialogEl, ref])}
onClick={handleDialogClick}
onClick={handleDialogClose}
onClose={handleDialogClose}
{...rest}
>
<form
Expand Down

0 comments on commit d71099a

Please sign in to comment.