From 9e4dedc987eef83045add7e09b0c11335967397a Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Wed, 3 Jun 2026 02:58:34 -0400 Subject: [PATCH] fix(theme): guard nav-state.js against duplicate toggle listeners --- ZB.MOM.WW.Theme/src/ZB.MOM.WW.Theme/wwwroot/js/nav-state.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ZB.MOM.WW.Theme/src/ZB.MOM.WW.Theme/wwwroot/js/nav-state.js b/ZB.MOM.WW.Theme/src/ZB.MOM.WW.Theme/wwwroot/js/nav-state.js index 4715c17..92c054a 100644 --- a/ZB.MOM.WW.Theme/src/ZB.MOM.WW.Theme/wwwroot/js/nav-state.js +++ b/ZB.MOM.WW.Theme/src/ZB.MOM.WW.Theme/wwwroot/js/nav-state.js @@ -1,10 +1,14 @@ // ZB.MOM.WW.Theme nav-state.js — persists
open/closed // state in localStorage so NavRailSection expand state survives navigation and // reloads. Pure client-side; works with static Blazor SSR. Keyed per section. +// localStorage keys are prefixed with "zbnav:" to avoid collisions. (function () { var PREFIX = "zbnav:"; + var INIT_ATTR = "data-zbnav-initialized"; function apply() { document.querySelectorAll("details.rail-section[data-nav-key]").forEach(function (el) { + if (el.hasAttribute(INIT_ATTR)) return; // already wired — avoid duplicate listeners + el.setAttribute(INIT_ATTR, ""); var key = PREFIX + el.getAttribute("data-nav-key"); var saved = null; try { saved = window.localStorage.getItem(key); } catch (e) { return; }