GeneratePress Sticky Nav on scroll up – Kadence Modal Open Fix

JavaScript
document.addEventListener('DOMContentLoaded', function () {
    // Function to toggle the display of .is_stuck
    function toggleIsStuckDisplay() {
        const body = document.body;
        const isStuckElement = document.querySelector('.sticky-enabled .main-navigation.is_stuck');
        
        if (body && body.classList.contains('kt-modal-open')) {
            if (isStuckElement) {
                isStuckElement.style.display = 'none';
            }
        } else {
            if (isStuckElement) {
                isStuckElement.style.display = '';
            }
        }
    }

    // Observe changes to the class list on the body
    const bodyObserver = new MutationObserver(toggleIsStuckDisplay);
    bodyObserver.observe(document.body, { attributes: true, attributeFilter: ['class'] });

    // Run initially in case the body already has the class
    toggleIsStuckDisplay();
});