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; }