Skip to content

Commit b95a0da

Browse files
authored
Merge pull request #28 from Yugveer06/main
Close modal when clicking outside
2 parents e2bf612 + 35c3c8b commit b95a0da

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/components/SnippetModal.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ const SnippetModal: React.FC<Props> = ({
2323
useEscapeKey(handleCloseModal);
2424

2525
return ReactDOM.createPortal(
26-
<div className="modal-overlay">
26+
<div
27+
className="modal-overlay"
28+
onClick={(e) => {
29+
if (e.target === e.currentTarget) {
30+
handleCloseModal();
31+
}
32+
}}
33+
>
2734
<div className="modal | flow" data-flow-space="lg">
2835
<div className="modal__header">
2936
<h2 className="section-title">{snippet.title}</h2>

0 commit comments

Comments
 (0)