Bug Report: SSR font flicker caused by design-system styles loading after the initial render
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
- Lĩnh vực
- build-system, frontend
Hướng nghiên cứu
Start by tracing how DiamondDSTokens.css and DiamondDSTypography.css are injected with style-inject, then compare that path with the existing font-styles.css pattern and the package imports shown in the issue. Check the package's SSR behavior with MUI and Emotion. Done means token and typography variables are available before the first paint without relying on browser-only injection.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
SciReactUI 0.7.1 addressed font-loading issues in some applications by externalising the font CSS. However, this revealed a separate issue affecting server-side rendering.
In SSR applications such as EVO, DiamondDS tokens and typography variables are unavailable during the initial render. This can cause text to appear briefly in a fallback serif font before switching to Inter or another configured typeface. Other token-dependent styles may also change after the initial render, although these changes are likely to be less noticeable.
Expected behaviour
Design-system tokens and typography styles should be available before the first paint.
Actual behaviour
DiamondDSTokens.css and DiamondDSTypography.css are injected in the browser using style-inject.
Because style-inject does not run on the server, variables such as --ds-font-family-default are initially undefined. They become available only after the application renders, causing a visible font change.
The application’s MUI and Emotion SSR configuration works correctly for styles generated through Emotion. It cannot collect these separate CSS files.
See MUI's SSR guide for an explanation of its server-rendering mechanism.
Environment
- Package version:
@diamondlightsource/[email protected] - Browser: Any modern browser
- OS: Any
- App or framework environment: Server-side rendered React application using MUI and Emotion
Additional context
A temporary consumer workaround is to define the font variables in server-rendered global CSS:
:root {
--ds-font-family-default: "Inter Variable", system-ui, sans-serif;
--ds-font-family-display:
"Outfit Variable", "Inter Variable", system-ui, sans-serif;
--ds-font-family-mono: "IBM Plex Mono", ui-monospace, monospace;
}
A possible package fix is to publish the design tokens and typography rules as a static CSS export, following the existing font-styles.css pattern:
import '@diamondlightsource/sci-react-ui/font-styles.css';
import '@diamondlightsource/sci-react-ui/styles.css';
This would allow the consuming framework to include the styles before first paint. These foundational styles would no longer need to be injected at runtime using style-inject.
We can also unify both files into a single one.
A separate font swap may still occur while the .woff2 files download because font-styles.css uses font-display: swap (better for displaying content quickly). Applications can reduce that delay by preloading fonts used above the fold.
- Ngôn ngữ chính
- TypeScript
- Star
- 9
- Fork
- 3
- Merge trung bình
- 6 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 20
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của DiamondLightSource/sci-react-ui
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
DiamondLightSource/sci-react-ui#325 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
accepted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
DiamondLightSource/sci-react-ui#283 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
needs-triage
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
DiamondLightSource/sci-react-ui#332 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
needs-triage
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
DiamondLightSource/sci-react-ui#331 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
needs-triage
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
DiamondLightSource/sci-react-ui#280 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của DiamondLightSource/sci-react-ui
Issue tương tự
-
Mend: dependency security vulnerability untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
opensearch-project/security-dashboards-plugin#2545 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: Dream TR SDĐang mởcheck:passed streams:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
doctor integrity sample scans soft-deleted pages on Postgres (batch path has no deleted_at filter)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
SocialGouv/egapro#4672 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
area:agents area:tui bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
anthropics/claude-code#98358 ·
Maintainer thường phản hồi trong vòng 1 ngày