From e07496bf91c20a2da818339cb7eec6ffee6257d5 Mon Sep 17 00:00:00 2001 From: HighImKevin Date: Sat, 17 Oct 2026 13:31:02 -0400 Subject: [PATCH] Ensure Mui style for active header buttons in the top main nav --- scripts/utils.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/utils.js b/scripts/utils.js index e0df982..75669a8 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -1631,6 +1631,18 @@ return entry ? getCustomMenuLinkHref(entry) : ''; } + /** Match native v12 top-nav: Inherit when idle, Primary when selected. */ + function applyMuiTopNavColorVariant(el, active) { + if (!el?.classList?.contains('MuiButton-root')) return; + if (active) { + el.classList.remove('MuiButton-textInherit', 'MuiButton-colorInherit'); + el.classList.add('MuiButton-textPrimary', 'MuiButton-colorPrimary'); + } else { + el.classList.remove('MuiButton-textPrimary', 'MuiButton-colorPrimary'); + el.classList.add('MuiButton-textInherit', 'MuiButton-colorInherit'); + } + } + function syncCustomTopNavActiveState() { const links = Array.from(document.querySelectorAll('[data-kefin-custom-menu-top-link]')); if (!links.length) return; @@ -1642,6 +1654,7 @@ links.forEach((el) => { el.classList.remove('active'); + applyMuiTopNavColorVariant(el, false); const score = customTopNavHrefMatchScore(resolveCustomTopNavHref(el), normalizedHash); if (score < 0) return; if (score > bestScore) { @@ -1653,7 +1666,10 @@ } }); - winners.forEach((el) => el.classList.add('active')); + winners.forEach((el) => { + el.classList.add('active'); + applyMuiTopNavColorVariant(el, true); + }); } let customTopNavActiveSyncBound = false;