Browse Source

Fix lightbox JS error on close (#948)

Fixes #946

Co-authored-by: Phil S <ullarah@noreply@mills.io>
Reviewed-on: #948
Co-authored-by: Phil S. <ullarah@noreply@mills.io>
Co-committed-by: Phil S. <ullarah@noreply@mills.io>
main
Phil S. 1 week ago committed by James Mills
parent
commit
7ba103dd1d
  1. 6
      internal/theme/static/js/98-modal.js

6
internal/theme/static/js/98-modal.js

@ -17,8 +17,8 @@ let visibleModal = null;
const toggleModal = event => {
event.preventDefault();
const modal = document.getElementById(event.target.getAttribute('data-target'));
(typeof(modal) != 'undefined' && modal != null)
&& isModalOpen(modal) ? closeModal(modal) : openModal(modal)
(typeof(modal) != 'undefined' && modal != null) &&
isModalOpen(modal) ? closeModal(modal) : openModal(modal)
}
// Is modal open
@ -53,7 +53,7 @@ const closeModal = modal => {
// Close with a click outside
document.addEventListener('click', event => {
if (visibleModal != null) {
const modalContent = visibleModal.querySelector('article');
const modalContent = visibleModal.querySelector('figure');
const isClickInside = modalContent.contains(event.target);
!isClickInside && closeModal(visibleModal);
}

Loading…
Cancel
Save