Skip to content

fix(AppShell): with the standard width points, a server-rendered top nav hides its start and center content on a phone before its script runs - #12452

Closed
josephfarina wants to merge 2 commits into
mainfrom
josephfarina/top-nav-phone-first-paint
Closed

josephfarina wants to merge 2 commits into
mainfrom
josephfarina/top-nav-phone-first-paint

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

On a phone, a server-rendered AppShell with a TopNav paints the server's wide layout until the page's script runs, because the shell picks its phone layout from a media query in the browser (component:AppShell FR8). AppShell already stops the inline side nav from painting in that frame. The top nav still painted its full row: heading, every link and the end content. On a phone that row wraps, so the bar grows and then snaps back to one line when the script runs, and a theme that gives the header a fixed height paints the wrapped links outside the bar for that frame.

Now, while the shell has not read the window, and only when the top nav will take its phone bar (component:AppShell FR9: mobileNav is not false and not a node, the breakpoint is not none, no defaultIsMobile), the full bar hides its start and center content below the breakpoint, so the first paint shows only the heading and the end content, as the phone bar does (component:TopNav FR5). It is still the full bar: the menu toggle arrives with the script, as for the side nav, and a heading too wide to share the row with the end content still moves the end content to a second line until then. A theme that moves the width point keeps today's first paint.

  • AppShell/unreadWidthPoint.ts (new, private to AppShell): the one module that writes the standard width points as media keys. unreadWidthPoint() decides, once, whether the shell shows its phone layout through CSS before it reads the window (the window is unread and the theme keeps the standard point; StyleX compiles media queries ahead of time, so a theme that moves the point keeps today's behavior). UNREAD_STYLES holds each point's rules: the inline side nav and elevated corner (moved here from AppShell.tsx, unchanged) and the top nav's start and center regions (not all and (min-width), which stops at the point itself).
  • AppShell.tsx: computes the point once, styles its side nav and corner from it, and hands the top nav its region rule through a private context, so TopNav does not import AppShell's width-point module. The context wraps the full bar on every render, so reading the window does not remount it.
  • TopNav.tsx: applies the region rule it reads from that context to the start and center regions.
  • TopNavRenderContext.ts: the private context (TopNavUnreadRegionContext). Not exported from the package.
  • touchPresentation.test.ts: the width-point spellings are allowed only in unreadWidthPoint.ts.
  • No spec change: the records already say the phone layout applies below the breakpoint; this makes the server frame match them.

Measured in Chromium on a server-rendered page with a theme whose header is 40px tall, script disabled:

width before after
390 5 links painted, all outside the bar none painted; heading in the bar
767 5 links painted, all outside the bar none painted
768, 1280 full bar full bar (unchanged)

With the script on, every width is unchanged.

Test plan:

  • CI=1 vitest run --project ui packages/core/src/AppShell packages/core/src/TopNav (397 pass) and packages/core/src/utils/touchPresentation.test.ts (13 pass). New: server HTML hides start and center below the breakpoint and keeps the heading and end content; the selected width point; no rule for mobileNav={false}, a node, defaultIsMobile, none, a moved width point, or a TopNav outside AppShell; hydration drops the rule at both widths and keeps the full bar's element above the breakpoint.
  • tsc --noEmit for core, eslint and prettier on the touched files.

preflight: pass 2a811eb

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 19, 2026 11:13am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@astracat-bot

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 19, 2026, 11:20 AM UTC

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: the server-rendered top nav now keeps its start and center links off a phone's first paint, and widths at or above the breakpoint paint exactly as before, but the title promises more than the change does.

  • The title says a server-rendered top nav "paints its phone bar" before its script runs, but the first paint is still the full bar with its start and center content hidden: it has no menu toggle, it applies only with the standard width points, and a heading too wide to share the row still wraps the end content to a second line (an 80 px bar at 390 px, where the phone bar is 48 px), so retitle it, for example fix(AppShell): with the standard width points, a server-rendered top nav hides its start and center content on a phone before its script runs.

The new top nav tests fail on the base and pass on this head, and server-rendered frames at 390, 767, 768 and 1280 px match the changeset. Two optional comment-style suggestions are inline. CI's test and build jobs have not run on this head yet.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Title: the server paints the top nav's phone bar before the script runs: false (no toggle; standard width points only; a long heading still wraps the end content, 80 px against 48 px at 390 px).
  • Changeset: with the standard width points, a server-rendered page on a phone no longer paints the top nav's full row of links while its script loads: verified (server-rendered frames at 390 and 767 px show no links; new server-HTML test).
  • Changeset: the bar shows its heading and end content, as the phone bar does: verified for the content shown (the server-HTML test keeps the heading and end content outside the hidden regions).
  • Changeset: the menu toggle still arrives with the script: verified (no toggle in the first paint; the hydration test reaches the mobile bar).
  • Changeset: a patch release of core: consistent (no public API change).
  • Description: stacked on the side-nav pull request: verified (this branch's base is that pull request's head).
  • Description: without the SSR hint the server HTML is the wide layout, because the shell reads its phone layout from a media query: verified (AppShell.tsx:705-728).
  • Description: before, the full bar painted the heading, every link and the end content, and the row wraps on a phone: verified (base frame at 390 px: a 128 px bar with the links on a second row).
  • Description: a theme with a fixed-height header paints the wrapped links outside the bar: verified at 390 px with a 40 px bar (all five links below it on the base; none painted on the head).
  • Description: the rule applies only while the top nav will take its phone bar and the theme keeps the standard width point: verified (AppShell.tsx:1011-1024; the six "adds no rule" tests).
  • Description: reading the window does not remount the full bar: verified (AppShell.tsx:1031-1035; the hydration test keeps the server's nav element above the breakpoint).
  • Description: one compiled rule per standard width point that stops at the point itself: verified (TopNav.tsx:51-78; hidden at 767 px, the 768 px frame identical to the base).
  • Description: the new context is not exported from the package: verified (TopNav/index.ts:33-34; the API report lists no change).
  • Description: the guard test allows the width-point spellings in TopNav: verified (touchPresentation.test.ts:383-390).
  • Description: no spec change is needed: verified (the AppShell and TopNav records already put the phone bar below the breakpoint, without start or center content).
  • Description: measured table (links gone at 390 and 767 px, 768 and 1280 px unchanged): verified at 390, 768 and 1280 px and for the hidden links at 767 px; whether the base's links fall outside the bar at 767 px depends on the bar's content.
  • Description: with the script on, every width is unchanged: verified for the hydrated result on both sides of the breakpoint (hydration tests).
  • Description: the listed test run passes, 953 tests: verified (953 passed); typecheck, eslint and prettier on the touched files: verified (clean).
  • File .changeset/top-nav-phone-first-paint.md: clear.
  • File packages/core/src/AppShell/AppShell.test.tsx: clear.
  • File packages/core/src/AppShell/AppShell.tsx: clear (optional comment-style suggestion inline).
  • File packages/core/src/TopNav/TopNav.tsx: clear (optional comment-style suggestion inline).
  • File packages/core/src/TopNav/TopNavRenderContext.ts: clear.
  • File packages/core/src/utils/touchPresentation.test.ts: clear.

Automated review (maintainer link)

Comment thread packages/core/src/TopNav/TopNav.tsx Resolved
Comment thread packages/core/src/AppShell/AppShell.tsx Resolved
@josephfarina

Copy link
Copy Markdown
Contributor Author

look gate: FAIL on the sample theme's own badge contrast and tab look (same as without this change); 0 header or phone layout problems at 390 and 1280.

@josephfarina
josephfarina marked this pull request as ready for review November 17, 2026 22:18
@josephfarina
josephfarina removed the request for review from imdreamrunner November 17, 2026 22:18
@josephfarina josephfarina changed the title fix(AppShell): a server-rendered top nav paints its phone bar before its script runs fix(AppShell): with the standard width points, a server-rendered top nav hides its start and center content on a phone before its script runs Nov 17, 2026
@josephfarina
josephfarina force-pushed the josephfarina/top-nav-phone-first-paint branch from 67c3efe to 6936a30 Compare November 17, 2026 22:42

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet, since it runs only for pull requests into main or a release branch.

The retitle fixes the one blocking point from the last review: the title now says the server-rendered top nav hides its start and center content on a phone before its script runs, which is what this head does. Server-rendered pages at 390 and 767 px now paint no start or center links, and at 768 and 1280 px they paint exactly as before. One optional comment-style suggestion, which the last review missed, is inline.

Claims and files checked

Review mode: full; reason: history

  • Title: with the standard width points, a server-rendered top nav hides its start and center content on a phone before its script runs: verified (server-rendered frames at 390 and 767 px show no start or center links; the new server-HTML tests).
  • Changeset: a patch release of core: consistent (no public API change).
  • Changeset: with the standard width points, a server-rendered page on a phone no longer paints the top nav's full row of links while its script loads: verified (frames at 390 and 767 px; the moved-width-point test keeps today's paint).
  • Changeset: the bar shows only its heading and end content: verified (frames; the test keeps the heading and end content outside the hidden regions).
  • Changeset: the menu toggle still arrives with the script: verified (no toggle in the first paint; the hydration test reaches the mobile bar).
  • Description: stacked on the side-nav pull request: verified (this branch's base is that pull request's head).
  • Description: without the SSR hint the server paints the wide layout because the shell reads its phone layout from a media query: verified (AppShell.tsx:705-728).
  • Description: the base pull request already hides the inline side nav in that frame: verified (AppShell.tsx:540-610, :943-949).
  • Description: before, the full bar painted every link and the row wrapped on a phone: verified (base frame at 390 px: a 156 px bar).
  • Description: a fixed-height header painted the wrapped links outside the bar: verified at 390 px with a 40 px bar (five links and Sign in below it on the base; none on this head).
  • Description: the rule applies only while the top nav will take its phone bar and the theme keeps the standard width point: verified (AppShell.tsx:1011-1024; the six "adds no rule" tests).
  • Description: the first paint is still the full bar, without the toggle, and a too-wide heading still moves the end content to a second line: verified (a 72 px bar at 390 px with a long heading, against the phone bar's 48 px).
  • Description: a theme that moves the width point keeps today's first paint: verified (test and AppShell.tsx:1022).
  • Description: reading the window does not remount the full bar: verified (AppShell.tsx:1031-1035; the hydration test keeps the server's nav element above the breakpoint).
  • Description: one compiled rule per standard width point that stops at the point itself: verified (TopNav.tsx:50-77; hidden at 767 px, the 768 px frame identical to the base).
  • Description: the new context is not exported from the package: verified (TopNav/index.ts:33-34; the API comparison lists no change).
  • Description: the guard test allows the width-point spellings in TopNav: verified (touchPresentation.test.ts:304-308).
  • Description: no spec change is needed: verified (the AppShell and TopNav records already put the phone bar below the breakpoint, without start or center content).
  • Description: measured table: verified at 390, 768 and 1280 px and for the hidden links at 767 px; whether the base's links fall outside the bar at 767 px depends on the page's content (five short links fit one row in the review's page).
  • Description: with the script on, every width is unchanged: verified for the hydrated result on both sides of the breakpoint (hydration tests).
  • Description: the listed test run passes with 953 tests, and typecheck, eslint and prettier are clean: verified.
  • File .changeset/top-nav-phone-first-paint.md: clear.
  • File packages/core/src/AppShell/AppShell.test.tsx: clear (four of the new tests fail on the base and pass here).
  • File packages/core/src/AppShell/AppShell.tsx: clear.
  • File packages/core/src/TopNav/TopNav.tsx: clear.
  • File packages/core/src/TopNav/TopNavRenderContext.ts: one optional comment-style note (file header length), inline.
  • File packages/core/src/utils/touchPresentation.test.ts: clear.

Automated review (maintainer link)

@josephfarina
josephfarina changed the base branch from josephfarina/appshell-first-paint-phone to main November 19, 2026 05:42
@josephfarina
josephfarina force-pushed the josephfarina/top-nav-phone-first-paint branch from 6936a30 to 2fc9c95 Compare November 19, 2026 05:43
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 19, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 2fc9c95

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet.

On a phone, a server-rendered page now paints only the top nav's heading and end content before its script runs, and at 768 px and wider the first paint is unchanged. Nothing blocks. Two optional points: the file header in TopNavRenderContext.ts is still past the length the comment rules allow (inline from the last review), and the description still says this branch is stacked on #12396, whose change is now on main.

Claims and files checked

Review mode: full; reason: rebase

  • Title: with the standard width points, a server-rendered top nav hides its start and center content on a phone before its script runs: verified (server-rendered frames at 390 and 767 px show no start or center links; the new server-HTML tests).
  • Changeset: a patch release of core: consistent (no public API change).
  • Changeset: with the standard width points, a server-rendered page on a phone no longer paints the top nav's full row of links while its script loads: verified (frames at 390 and 767 px; the moved-width-point test keeps today's paint).
  • Changeset: the bar shows only its heading and end content: verified (frames; the test keeps the heading and end content outside the hidden regions).
  • Changeset: the menu toggle still arrives with the script: verified (no toggle in the first paint; the hydration test reaches the mobile bar).
  • Description: stacked on the side-nav pull request, to be reviewed first: out of date (that pull request is closed and its change is on main, where this branch now sits).
  • Description: without the SSR hint the server paints the wide layout because the shell reads its phone layout from a media query: verified (AppShell.tsx:705-729).
  • Description: the side-nav change already hides the inline side nav in that frame: verified (AppShell.tsx:541-611, :944-950).
  • Description: before, the full bar painted every link and the row wrapped on a phone: verified (base frame at 390 px: a 120 px bar).
  • Description: a fixed-height header painted the wrapped links outside the bar: verified at 390 px with a 40 px bar (five links and Sign in below it on the base; none on this head).
  • Description: the rule applies only while the top nav will take its phone bar and the theme keeps the standard width point: verified (AppShell.tsx:1012-1025; the six "adds no rule" tests).
  • Description: the first paint is still the full bar, without the toggle, and a too-wide heading still moves the end content to a second line: verified (a 72 px bar at 390 px with a long heading, against the phone bar's 48 px).
  • Description: a theme that moves the width point keeps today's first paint: verified (test and AppShell.tsx:1023).
  • Description: reading the window does not remount the full bar: verified (AppShell.tsx:1031-1037; the hydration test keeps the server's nav element above the breakpoint).
  • Description: one compiled rule per standard width point that stops at the point itself: verified (TopNav.tsx:50-77; hidden at 767 px, the 768 px frame identical to the base).
  • Description: the new context is not exported from the package: verified (TopNav/index.ts:33-34; the API comparison lists no change).
  • Description: the guard test allows the width-point spellings in TopNav: verified (touchPresentation.test.ts:304-308).
  • Description: no spec change is needed: verified (the AppShell and TopNav records already put the phone bar below the breakpoint, without start or center content).
  • Description: measured table: verified at 390, 768 and 1280 px and for the hidden links at 767 px; whether the base's links fall outside the bar at 767 px depends on the page's content (five short links fit one row in the review's page).
  • Description: with the script on, every width is unchanged: verified for the hydrated result on both sides of the breakpoint (hydration tests).
  • Description: the listed test run passes, and typecheck, eslint and prettier are clean: verified (the run now has 969 tests on this head, all passing).
  • File .changeset/top-nav-phone-first-paint.md: clear.
  • File packages/core/src/AppShell/AppShell.test.tsx: clear (four of the new tests fail on the base and pass here).
  • File packages/core/src/AppShell/AppShell.tsx: clear.
  • File packages/core/src/TopNav/TopNav.tsx: clear.
  • File packages/core/src/TopNav/TopNavRenderContext.ts: one optional comment-style note (file header length), inline from the last review.
  • File packages/core/src/utils/touchPresentation.test.ts: clear.

Automated review (maintainer link)

…nav hides its start and center content on a phone before its script runs

[skip ci]
… nav hide below before the shell reads the window

AppShell computes the unread width point once (unreadWidthPoint) and hands TopNav the compiled region rule through a private context, so TopNav does not import AppShell's width-point module. The compiled rules for every standard point (the inline side nav's, the elevated corner's and the top nav regions') live in AppShell/unreadWidthPoint.ts, private to AppShell and the only module that writes those media keys; the touch-presentation guard checks that single owner again.

[skip ci]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet.

On a phone, a server-rendered page now paints only the top nav's heading and end content before its script runs, and at 768 px and wider the first paint is unchanged; moving the width-point rules into one AppShell module changes no CSS. Nothing blocks. One optional point: the moved comment at the top of the rules in unreadWidthPoint.ts has two long sentences, with a suggested rewrite inline.

Claims and files checked

Review mode: full; reason: rebase

  • Before the script runs, a server-rendered shell on a phone paints the wide layout because it picks the phone layout from a media query in the browser: verified (AppShell.tsx:636-656).
  • AppShell already hides the inline side nav in that frame: verified (AppShell.tsx:866-879; the side-nav server-HTML test).
  • The full top bar painted every link, the row wrapped on a phone and snapped back at hydration, and a fixed-height header painted the wrapped links outside the bar: verified (base frames: a 124 px bar at 390 px; links below a 40 px bar).
  • The rule applies only while the window is unread and the top nav takes its phone bar (mobileNav not false or a node, breakpoint not none, no defaultIsMobile): verified (AppShell.tsx:941-950; four "adds no rule" tests).
  • The first paint then shows only the heading and the end content, as the phone bar does: verified (head frames at 390 and 767 px).
  • It is still the full bar: the toggle arrives with the script, and a heading too wide for the row still moves the end content to a second line: verified (no toggle in head frames; the full bar keeps its wrap rule, TopNav.tsx:56-59).
  • A theme that moves the width point keeps today's first paint: verified (unreadWidthPoint.ts:30-40; the moved-point test).
  • unreadWidthPoint.ts is the one module that writes the standard width points as media keys, and the side-nav and corner rules moved there unchanged: verified (repository search; the moved rules diff as identical).
  • The top-nav region rules use not all and (min-width) and stop at the point itself: verified (hidden at 767 px; the 768 px frame is identical to the base).
  • AppShell computes the point once and hands TopNav its rule through a private context, so TopNav does not import the width-point module: verified (AppShell.tsx:871-879, :947-961; TopNav imports only TopNavRenderContext).
  • The context wraps the full bar on every render, so reading the window does not remount it: verified (AppShell.tsx:956-961; the hydration test keeps the server's nav element above the breakpoint).
  • TopNav applies the rule to its start and center regions: verified (TopNav.tsx:351, :359).
  • The new context is not exported from the package: verified (TopNav/index.ts exports by name; the API comparison lists no change).
  • The guard test allows the width-point spellings only in unreadWidthPoint.ts: verified (touchPresentation.test.ts:315-322).
  • No spec change is needed: verified (no record changes; the AppShell and TopNav records already define the phone bar below the breakpoint).
  • Measured table: verified at 390, 768 and 1280 px and for the hidden links at 767 px; whether the base's links fall outside a 40 px bar at 767 px depends on the page (five short links fit one row in this review's page).
  • With the script on, every width is unchanged: verified for the hydrated result on both sides of the breakpoint (hydration tests).
  • The listed tests pass, and typecheck, eslint and prettier are clean: verified (410 tests pass on this head; all three checks clean).
  • Preflight passes on this head: the checks rerun here pass (tests, typecheck, eslint, prettier); the preflight command itself was not rerun.
  • Changeset: a patch release of core: consistent (no public API change).
  • Changeset: with the standard width points, a server-rendered page on a phone no longer paints the top nav's full row of links while its script loads: verified (frames at 390 and 767 px; the moved-point test keeps today's paint).
  • Changeset: the bar shows only its heading and end content: verified (head frames).
  • Changeset: the menu toggle still arrives with the script: verified (no toggle in head frames; the hydration test reaches the mobile bar).
  • File .changeset/top-nav-phone-first-paint.md: clear.
  • File packages/core/src/AppShell/AppShell.test.tsx: clear (four new tests fail on the merge base and pass here).
  • File packages/core/src/AppShell/AppShell.tsx: clear.
  • File packages/core/src/AppShell/unreadWidthPoint.ts: one optional comment-style note (lines 42-47).
  • File packages/core/src/TopNav/TopNav.tsx: clear.
  • File packages/core/src/TopNav/TopNavRenderContext.ts: clear (the earlier file-header note is fixed).
  • File packages/core/src/utils/touchPresentation.test.ts: clear.

Automated review (maintainer link)

Comment on lines +42 to +47
// One rule per standard width point (`DEFAULT_WIDTH_BREAKPOINTS`). The
// queries use `not all and (min-width)`: StyleX lowers `(width < N)` to
// `(max-width: N - 0.01)`, which Chromium rounds up to N, so the rule would
// also apply at the point itself. Below the point, the inline side nav does
// not paint, the elevated backdrop loses its corner, and the top nav's start
// and center regions do not paint, as in the phone layout.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional (comment style): two sentences here run about 30 words each, one on the StyleX and Chromium rounding quirk and one listing three effects. Suggested:

// One rule per standard width point (`DEFAULT_WIDTH_BREAKPOINTS`). Below the
// point, the inline side nav and the top nav's start and center regions do not
// paint. The elevated backdrop loses its corner. The queries use
// `not all and (min-width)`. StyleX lowers `(width < N)` to
// `(max-width: N - 0.01)`, and Chromium rounds that up to N. That rule would
// also apply at the point itself.

josephfarina added a commit that referenced this pull request Nov 19, 2026
- #12452 fix(AppShell): with the standard width points, a server-rendered top nav hides its start and center content on a phone before its script runs
  Author: @josephfarina
- #12368 feat(Table): table rows expose their stripe to themes (parity, striped)
  Author: @josephfarina
- #12646 fix(themes): a plain table's rows keep their text; only a striped table's rows take the stripe's
  Author: @josephfarina
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #12894.

@github-actions
github-actions Bot deleted the josephfarina/top-nav-phone-first-paint branch November 20, 2026 06:06

This branch was successfully deployed

1 active deployment
Preview — 2a811eb7 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant