diff --git a/shared/nav.js b/shared/nav.js index 00b4bbc..c46ca2d 100644 --- a/shared/nav.js +++ b/shared/nav.js @@ -110,15 +110,18 @@ var header = document.querySelector('.app-header'); if (!header) return; // Don't double-mount if a tool's main.js calls us a second time. - if (header.nextElementSibling && - header.nextElementSibling.classList && - header.nextElementSibling.classList.contains('zddc-stage-strip')) { + if (header.previousElementSibling && + header.previousElementSibling.classList && + header.previousElementSibling.classList.contains('zddc-stage-strip')) { return; } var project = projectSegment(location.pathname); var active = currentStage(location.pathname); var strip = buildStrip(project, active); - header.parentNode.insertBefore(strip, header.nextSibling); + // Mount ABOVE the header — the strip is project-level chrome + // (where in the project), the header is tool-level chrome (which + // tool, theme, help). Reading order matches outer-to-inner scope. + header.parentNode.insertBefore(strip, header); } // Expose for tests + opt-out. diff --git a/tests/nav.spec.js b/tests/nav.spec.js index 4dbd79e..95f9c26 100644 --- a/tests/nav.spec.js +++ b/tests/nav.spec.js @@ -79,13 +79,13 @@ test.describe('shared/nav.js stage strip', () => { ]); }); - test('mounts immediately under the app-header', async ({ page }) => { + test('mounts immediately above the app-header', async ({ page }) => { await page.goto(`${baseUrl}/projA/archive.html`, { waitUntil: 'load' }); - const next = await page.evaluate(() => { + const prev = await page.evaluate(() => { const h = document.querySelector('.app-header'); - return h && h.nextElementSibling && h.nextElementSibling.className; + return h && h.previousElementSibling && h.previousElementSibling.className; }); - expect(next).toContain('zddc-stage-strip'); + expect(prev).toContain('zddc-stage-strip'); }); });