Hi Seamus,
This one is a very tough one, but I think I see the problem. As far as I can tell, you are trying to reatain the results opened, when the user closes the modal via the “Back to Results” button. However there is a setting for that here. When that option is turned off, the results will not close whenever the user clicks away from the container.
Therefore you can simplify the closeModal function like so:
function closeModal() {
const $modal = $('#artwork-zoom-modal');
$modal.attr('data-stage', '1');
$modal.css('display', 'none');
$('.artwork-modal-bg-stage1, .artwork-modal-bg-stage2').addClass('hidden').css('display', 'none');
$('.artwork-modal-stage1, .artwork-modal-stage2').addClass('hidden').css('display', 'none');
$('body').removeClass('modal-open overflow-hidden');
}
I’m almost a 100% sure that this is going to fix the issue, as the visibility was all over the place in the original closeModal function, which caused the problem with the isotope recalculation.