diff --git a/resources/js/site-nav.js b/resources/js/site-nav.js index 9f15e27..4fa19d5 100644 --- a/resources/js/site-nav.js +++ b/resources/js/site-nav.js @@ -103,7 +103,7 @@ function setupMode(header, closeMenu) { // Unsichtbare Kopie von Navigation und Kontozugang in Desktop-Darstellung: liefert die benötigten Breiten in jedem Modus. const probe = document.createElement('div'); - probe.className = 'site-header site-nav-probe'; + probe.className = 'site-nav-probe'; probe.setAttribute('aria-hidden', 'true'); probe.style.cssText = 'position:absolute;visibility:hidden;pointer-events:none;left:-10000px;top:0;height:auto;padding:0;width:max-content;'; const nav = document.createElement('nav'); @@ -111,16 +111,27 @@ function setupMode(header, closeMenu) { nav.appendChild(list.cloneNode(true)); const accountProbe = account.cloneNode(true); probe.append(nav, accountProbe); - probe.querySelectorAll('[id]').forEach((node) => node.removeAttribute('id')); - probe.querySelectorAll('a, button').forEach((node) => node.setAttribute('tabindex', '-1')); + // Die Kopie ist reine Messfläche: nicht bedienbar, nicht vorgelesen, ohne Kennungen, Ziele und Skript-Merkmale. + probe.inert = true; + probe.querySelectorAll('*').forEach((node) => { + [...node.attributes] + .filter((attribute) => attribute.name === 'id' || attribute.name === 'href' || attribute.name.startsWith('aria-') || attribute.name.startsWith('data-')) + .forEach((attribute) => node.removeAttribute(attribute.name)); + }); document.body.appendChild(probe); const width = (element) => element.getBoundingClientRect().width; + const realNav = header.querySelector('.site-nav'); + let lastNavMargin = 32; const update = () => { const gap = parseFloat(getComputedStyle(inner).columnGap) || 0; const actionsGap = parseFloat(getComputedStyle(actions).columnGap) || 0; - const navMargin = parseFloat(getComputedStyle(nav).marginLeft) || 0; + // Abstand zwischen Wortmarke und Navigation in Desktop-Darstellung; im Menümodus der zuletzt gemessene Wert. + if (!isMenuMode(header)) { + lastNavMargin = parseFloat(getComputedStyle(realNav).marginLeft) || 0; + } + const navMargin = BASELINE.matches ? 0 : lastNavMargin; let fixedActions = width(actions) - width(account); if (menuButton && menuButton.offsetParent !== null) { fixedActions -= width(menuButton) + actionsGap;