Skip to content

Commit 47e1762

Browse files
authored
Allow the modal to close when we click outside the modal content (#1897)
1 parent 245dbdf commit 47e1762

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

assets/js/modal.js

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ function renderModal () {
3434
qs(MODAL_CLOSE_BUTTON_SELECTOR).addEventListener('click', event => {
3535
closeModal()
3636
})
37+
38+
qs(MODAL_SELECTOR).addEventListener('click', event => {
39+
const classList = event.target.classList
40+
// if we clicked on the modal overlay/parent but not the modal content
41+
if (classList.contains('modal') && classList.contains('shown') && classList.length === 2) {
42+
closeModal()
43+
}
44+
})
3745
}
3846

3947
/**

0 commit comments

Comments
 (0)