From 1b97fd67d019b45463e1d85dc6ae53a9fe49a81c Mon Sep 17 00:00:00 2001 From: Peter Knight Date: Mon, 13 Jul 2026 21:13:05 +0100 Subject: [PATCH] Fix mobile menu collapsing on scroll in iOS Safari iOS Safari fires a resize event when scrolling because the browser address bar hide/show changes window.innerHeight. The initResizeHandler was unconditionally hiding the nav on every mobile resize, collapsing a menu the user had intentionally opened. Guard the classList.add('hidden') call so it only runs when the menu is not currently expanded (aria-expanded !== 'true'). Co-authored-by: Cursor --- themes/le-2025/assets/js/le-2025-theme.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/themes/le-2025/assets/js/le-2025-theme.js b/themes/le-2025/assets/js/le-2025-theme.js index fd2a60dcf8..5a056a88b1 100644 --- a/themes/le-2025/assets/js/le-2025-theme.js +++ b/themes/le-2025/assets/js/le-2025-theme.js @@ -308,8 +308,13 @@ const Menu = { mainNav.classList.remove('hidden'); mobileMenuToggle.setAttribute('aria-expanded', 'false'); } else if (isMobile && mainNav && mobileMenuToggle) { - // Only hide the nav when in true mobile mode (< 768px) - mainNav.classList.add('hidden'); + // Only hide the nav when in true mobile mode (< 768px) and the menu + // is not intentionally open. On iOS Safari, scrolling fires a resize + // event (address bar hide/show changes innerHeight), which would + // otherwise collapse an open menu mid-scroll. + if (mobileMenuToggle.getAttribute('aria-expanded') !== 'true') { + mainNav.classList.add('hidden'); + } } else { // For tablet sizes (768px-1023px), keep the nav visible mainNav.classList.remove('hidden');