From 6404b7f8c522e60f5172afd48d18f31973744726 Mon Sep 17 00:00:00 2001 From: mariacha Date: Tue, 12 Nov 2024 12:22:47 -0800 Subject: [PATCH] Fixing click behavior if the menu is not found. --- .../ts_wrin/js/components/ts_header_nav.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/themes/custom/ts_wrin/js/components/ts_header_nav.js b/themes/custom/ts_wrin/js/components/ts_header_nav.js index 2ff9c9ed3..12da3a0e5 100644 --- a/themes/custom/ts_wrin/js/components/ts_header_nav.js +++ b/themes/custom/ts_wrin/js/components/ts_header_nav.js @@ -340,12 +340,14 @@ export default function(context) { }); } - // Close the menu if clicking outside of it - document.addEventListener("click", function() { - if (menuContainer.classList.contains("menu-open")) { - menuContainer.classList.remove("menu-open"); - menuContainer.classList.add("menu-closed"); - } - }); + if (menuContainer) { + // Close the menu if clicking outside of it + document.addEventListener("click", function() { + if (menuContainer.classList.contains("menu-open")) { + menuContainer.classList.remove("menu-open"); + menuContainer.classList.add("menu-closed"); + } + }); + } } }