document.addEventListener('DOMContentLoaded', function() {
var searchPopup = document.querySelector('.m-search-popup--wrapper');
searchPopup.addEventListener('click', function(event) {
// Close the search popup only if the click occurred outside the search form
if (!event.target.closest('.m-search-popup__search-form')) {
closeSearchPopup();
}
});
function closeSearchPopup() {
var searchPopup = document.querySelector('.m-search-popup');
searchPopup.style.visibility = 'hidden';
}
});