Fix media modal unable to close from image

This commit is contained in:
Alex Gleason 2021-05-17 22:59:51 -05:00
parent bca6852b94
commit 8cd0f594a0
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -119,9 +119,14 @@ class MediaModal extends ImmutablePureComponent {
}
}
handleCloserClick = e => {
handleCloserClick = ({ target }) => {
const whitelist = ['zoomable-image'];
const activeSlide = document.querySelector('.media-modal .react-swipeable-view-container > div[aria-hidden="false"]');
if (e.target === activeSlide || !activeSlide.contains(e.target)) {
const isClickOutside = target === activeSlide || !activeSlide.contains(target);
const isWhitelisted = whitelist.some(w => target.classList.contains(w));
if (isClickOutside || isWhitelisted) {
this.props.onClose();
}
}