Repository navigation
[docs-infra] Preserve normal body font weight - #49455
Conversation
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix addresses the webpack regression and includes appropriate end-to-end coverage.
0 open findings
What changed in this PR
Preserves normal body font weight while retaining General Sans preload behavior.
Changes:
- Applies General Sans through its CSS-variable class.
- Adds hydrated and server-rendered font-weight regression tests.
| File | Description |
|---|---|
packages-internal/core-docs/src/nextFonts/index.ts |
Prevents General Sans weight 600 from affecting the body. |
test/e2e-website/docs-fonts.spec.ts |
Verifies body and heading weights with JavaScript enabled and disabled. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Next registers and preloads the font from its import, so the variable class is not necessary. Check that the General Sans 600 font face loads in the hydrated test, and use the shared test fixture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Is there a Next.js ticket? What is the right behavior? This solution feels like a code smell, one of the two is a bug and the one this PR chooses feels awfully unintuitive. Also another indicator we need to think about running our screenshot regressions against the actual docs site. |
After #48842, the General Sans loader registers only weight 600 for preload. In webpack builds, Next adds that weight to its generated class, which is applied to
body. This overrides the normal body weight and makes plain paragraphs, labels, and legends semibold.The docs production build uses webpack. The default
pnpm startcommand uses Turbopack, whose generated font class does not set this weight, so that dev server does not reproduce the regression.Leave the General Sans class off
bodyso these elements inherit weight 400. Next registers and preloads the font from its import, not from the class, so the font faces and preload settings do not change. Add website tests for normal body text and semibold headings. Run each test with JavaScript enabled and with JavaScript disabled. The hydrated test also checks that the General Sans 600 font face loads.Reproduce on the deployed master Modal page. Under Nested modal, click Open modal. The paragraph with ID
parent-modal-descriptioninherits weight 600 instead of 400.Deployed fixed docs.
The live
mui.comdocs update with stable releases and currently use older source, so they do not yet show this regression.Validation:
Built the actual docs installation page in production mode with webpack, with the export limited to that page. Both font tests fail before the fix at body weight 600 and pass after the fix at weight 400. Each result was checked with JavaScript enabled and with JavaScript disabled.
Also reproduced the regression on the webpack dev server.
On the webpack dev server, the font tests pass in both modes, and the page preloads the same three font files as before.
Browser audit confirmed body weight 400, heading weight 600, unchanged font faces, and the same three preloaded font files.
I have followed (at least) the PR section of the contributing guide.