From 8390dcdb41b5fa05559304f8a2a2b9990950f8af Mon Sep 17 00:00:00 2001 From: Lars Date: Wed, 18 Nov 2026 06:55:25 +0100 Subject: [PATCH] =?UTF-8?q?Schirme=20die=20Messkopie=20der=20Navigation=20?= =?UTF-8?q?vollst=C3=A4ndig=20ab.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Die unsichtbare Kopie für die Breitenmessung trug Kennungen, Ziele und Skript-Merkmale der echten Navigation sowie die Klasse site-header. Sie ist jetzt inert, ohne id, href, aria- und data-Attribute und ohne Kopfzeilenklasse; der Abstand zur Wortmarke wird an der echten Navigation gemessen. Co-Authored-By: Claude Opus 5.5 --- resources/js/site-nav.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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;