Skip to content

Commit

Permalink
backdrop click on modal closes the modal
Browse files Browse the repository at this point in the history
  • Loading branch information
corn-potage committed Aug 25, 2024
1 parent abf5dd1 commit 35d2226
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/renderer/Generics/redesign/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,18 @@ export const Modal = ({
return () => {};
}, []);

const handleBackdropClick = useCallback(
(event: React.MouseEvent<HTMLDivElement>) => {
// Check if the click target is the backdrop itself
if (event.target === event.currentTarget) {
modalOnClose();
}
},
[modalOnClose],
);

return (
<div className={modalBackdropStyle}>
<div className={modalBackdropStyle} onClick={handleBackdropClick}>
<div className={[modalContentStyle, modalStyle].join(' ')}>
{modalType === 'modal' && (
<ContentHeader
Expand Down

0 comments on commit 35d2226

Please sign in to comment.