Unverified Commit a18b9a58 authored by Aurora Scharff's avatar Aurora Scharff Committed by GitHub

Fix dev overlay header layout on small screens (#99049)

## Summary

On narrow screens, the dev overlay header clips the version/bundler
badge and wraps “No issues” while hiding its horizontal scrollbar. Below
768px, the header now wraps its items onto a second row when needed. The
empty Issues tab stays visible, the version pill keeps its desktop
dimensions and rounded shape, and the mobile header has balanced spacing
above the tabs and below the pill. The wide-screen layout is unchanged.

This changes the shared overlay header independently of #99002.

## Before / after

Both images use the same /insight-only route at a 390 CSS-pixel
viewport, captured directly in Chrome as PNGs. The empty Issues tab
remains visible, and the version and bundler metadata move to a balanced
second row.

<table>
  <thead>
    <tr>
      <th>Before</th>
      <th>After</th>
    </tr>
  </thead>
  <tbody>
    <tr>
<td><img width="390" height="300" alt="Before: clipped version badge and
wrapped empty Issues label at 390px"
src="https://github.com/user-attachments/assets/a5e21308-0be1-4cb3-b4a8-101b3b793ff3"
/></td>
<td><img width="390" height="300" alt="After: balanced wrapped header
and fully visible rounded version pill at 390px"
src="https://github.com/user-attachments/assets/9bcd65cf-bdf3-402e-b121-0c66f0d63800"
/></td>
    </tr>
  </tbody>
</table>

## Wider screens — after

The header stays on one row at both widths, with no horizontal overflow.
The version pill retains its desktop dimensions and styling.

**768px viewport**

<img width="768" height="300" alt="After at 768px: navigation and
version pill fit on one row"
src="https://github.com/user-attachments/assets/f8994ca2-6d90-469a-b0df-a9d37165d838"
/>

**1280px viewport** (cropped to the overlay)

<img width="1000" height="300" alt="After at 1280px: unchanged desktop
header layout"
src="https://github.com/user-attachments/assets/e27eef41-d477-42f7-bcf3-224a1675e919"
/>

## Verification

- `pnpm test-dev-turbo
test/development/app-dir/instant-insights-tab-overlay/instant-insights-tab-overlay.test.ts`
— all 5 tests passed.
- Browser checks at 390, 768, and 1280 CSS-pixel widths confirm that the
empty Issues tab remains visible, the pill keeps its 230.96 × 24px
desktop dimensions and rounding, the mobile header has balanced spacing,
and the wide-screen header remains on one row.
- JavaScript build, formatting, and ESLint passed. Full `pnpm build-all`
was attempted but blocked by the existing Rust workspace manifest error:
`default-features = false` cannot override the workspace's
`turbo-persistence` default features. Runtime verification used the
published canary.38 native binary.

<!-- NEXT_JS_LLM -->
parent e1131ee7
...@@ -97,13 +97,24 @@ export const styles = ` ...@@ -97,13 +97,24 @@ export const styles = `
@media (max-width: 767px) { @media (max-width: 767px) {
[data-nextjs-error-overlay-nav] { [data-nextjs-error-overlay-nav] {
overflow-x: auto; flex-wrap: wrap;
overflow-y: hidden; justify-content: flex-start;
scrollbar-width: none; column-gap: 8px;
-ms-overflow-style: none; row-gap: 0;
box-sizing: border-box;
padding: 6px 12px 12px;
&::-webkit-scrollbar { .error-overlay-nav-item {
display: none; max-width: 100%;
padding: 0;
&[data-side='left'] {
flex-grow: 1;
}
}
.error-overlay-tab {
white-space: nowrap;
} }
} }
} }
......
...@@ -35,6 +35,44 @@ describe('instant insights tab overlay', () => { ...@@ -35,6 +35,44 @@ describe('instant insights tab overlay', () => {
}) })
} }
function clickIndicatorPill(browser: Playwright) {
return browser.eval(`(() => {
const portal = document.querySelector('nextjs-portal');
const root = portal && portal.shadowRoot;
if (!root) return;
root.querySelector('[data-issues-open]')?.click();
})()`)
}
function getErrorOverlayNavLayout(browser: Playwright) {
return evalInPortal(browser, (root) => {
const nav = [
...root.querySelectorAll('[data-nextjs-error-overlay-nav]'),
].find((element: Element) => element.getBoundingClientRect().width > 0)
const left = nav?.querySelector('[data-side="left"]')
const right = nav?.querySelector('[data-side="right"]')
const leftContent = left?.firstElementChild
const rightContent = right?.firstElementChild
if (!nav || !leftContent || !rightContent) return null
return {
leftTop: leftContent.getBoundingClientRect().top,
leftBottom: leftContent.getBoundingClientRect().bottom,
leftEdge: leftContent.getBoundingClientRect().left,
rightTop: rightContent.getBoundingClientRect().top,
rightBottom: rightContent.getBoundingClientRect().bottom,
rightLeft: rightContent.getBoundingClientRect().left,
rightEdge: rightContent.getBoundingClientRect().right,
navRightEdge: nav.getBoundingClientRect().right,
navBottomEdge: nav.getBoundingClientRect().bottom,
navPaddingRight: parseFloat(getComputedStyle(nav).paddingRight),
navPaddingBottom: parseFloat(getComputedStyle(nav).paddingBottom),
clientWidth: nav.clientWidth,
scrollWidth: nav.scrollWidth,
}
})
}
function getErrorOverlayTabCounts(browser: Playwright) { function getErrorOverlayTabCounts(browser: Playwright) {
return evalInPortal(browser, (root) => { return evalInPortal(browser, (root) => {
const bar = root.querySelector('[data-nextjs-error-overlay-tab-bar]') const bar = root.querySelector('[data-nextjs-error-overlay-tab-bar]')
...@@ -119,6 +157,45 @@ describe('instant insights tab overlay', () => { ...@@ -119,6 +157,45 @@ describe('instant insights tab overlay', () => {
expect(await hasErrorOverlayTabBar(browser)).toBe(false) expect(await hasErrorOverlayTabBar(browser)).toBe(false)
}) })
it('should wrap the mobile overlay header only when it does not fit', async () => {
const browser = await next.browser('/issue-only')
await retry(async () => {
expect((await getIndicatorPillState(browser))?.text).toMatch(/1\s*Issue/i)
})
await browser.setDimensions({ width: 390, height: 844 })
await clickIndicatorPill(browser)
await retry(async () => {
const layout = await getErrorOverlayNavLayout(browser)
expect(layout).not.toBeNull()
expect(Math.abs(layout!.rightTop - layout!.leftTop)).toBeLessThan(4)
expect(
Math.abs(
layout!.navRightEdge - layout!.rightEdge - layout!.navPaddingRight
)
).toBeLessThan(2)
expect(layout!.scrollWidth).toBe(layout!.clientWidth)
})
await browser.setDimensions({ width: 320, height: 844 })
await retry(async () => {
const layout = await getErrorOverlayNavLayout(browser)
expect(layout).not.toBeNull()
expect(layout!.rightTop - layout!.leftTop).toBeGreaterThan(4)
expect(Math.abs(layout!.rightLeft - layout!.leftEdge)).toBeLessThan(2)
expect(Math.abs(layout!.rightTop - layout!.leftBottom)).toBeLessThan(2)
expect(
Math.abs(
layout!.navBottomEdge - layout!.rightBottom - layout!.navPaddingBottom
)
).toBeLessThan(2)
expect(layout!.scrollWidth).toBe(layout!.clientWidth)
})
})
it('should show an amber pill when only an Insight is present', async () => { it('should show an amber pill when only an Insight is present', async () => {
const browser = await next.browser('/') const browser = await next.browser('/')
await browser.elementByCss('a[href="/insight-only"]').click() await browser.elementByCss('a[href="/insight-only"]').click()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment