Skip to content

Commit

Permalink
feat: Allow the modal to close when we click outside the modal content
Browse files Browse the repository at this point in the history
  • Loading branch information
ashkan117 committed May 1, 2024
1 parent f8075a3 commit c9f9ff2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions assets/js/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ function renderModal () {
qs(MODAL_CLOSE_BUTTON_SELECTOR).addEventListener('click', event => {
closeModal()
})

qs(MODAL_SELECTOR).addEventListener('click', event => {
const classList = event.target.classList
// if we clicked on the modal overlay/parent but not the modal content
if (classList.contains('modal') && classList.contains('shown') && classList.length === 2) {
closeModal()
}
})

Check failure on line 44 in assets/js/modal.js

View workflow job for this annotation

GitHub Actions / Check JS

Block must not be padded by blank lines

}

/**
Expand Down

0 comments on commit c9f9ff2

Please sign in to comment.