Skip to content

Commit

Permalink
fix: add Typed Esc handler
Browse files Browse the repository at this point in the history
  • Loading branch information
lanberb committed Nov 28, 2022
1 parent c603659 commit a688c3e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/spindle-ui/src/Modal/AppealModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ const Frame = forwardRef<DialogHTMLElement, AppealModalProps>(
}
};

const handleTypeEscape = (
event: React.SyntheticEvent<DialogHTMLElement>,
) => {
setClosing(false);
// Detect Esc Key type
if (event.target == dialogEl.current) {
onClose && onClose(event);
}
};

const handleAnimationEnd = useCallback(
(event: AnimationEvent) => {
if (
Expand Down Expand Up @@ -106,7 +116,7 @@ const Frame = forwardRef<DialogHTMLElement, AppealModalProps>(
.trim()}
ref={mergeRefs([dialogEl, ref])}
onClick={handleDialogClick}
onClose={() => setClosing(false)}
onClose={handleTypeEscape}
{...rest}
>
<form
Expand Down

0 comments on commit a688c3e

Please sign in to comment.