perf(invoice-generator): fix high Cumulative Layout Shift (CLS) on desktop and mobile
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 66/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- nextjs, react, typescript
- 领域
- frontend, performance
调研方向
Start in app/(tools)/invoice-generator/InvoiceGeneratorClient.tsx, where the current state begins as null and the Loading… placeholder section renders until the useEffect reads localStorage. Reproduce the shift with a Lighthouse run on the production URL to confirm the FAQ and CTA sections move. Done when the median CLS is at or below 0.1 on both desktop and mobile, with the skeleton matching the toolbar, editor and preview dimensions.
由索引模型根据 Issue 内容生成。
描述
Problem
During the baseline performance audit (#28), the Invoice Generator page was found to have severe Cumulative Layout Shift (CLS), failing the Core Web Vitals threshold of CLS ≤ 0.1 on both desktop and mobile.
Affected Production URL
https://tools.codercops.com/invoice-generator
Device
Desktop and Mobile
Measured Evidence
Lighthouse performance audit results (median of 3 runs on 2026-10-14, failing threshold is CLS > 0.1):
- Desktop Median CLS: 0.554 (individual runs: 0.555, 0.554, 0.554) — FAIL
- Mobile Median CLS: 0.465 (individual runs: 0.465, 0.465, 0.465) — FAIL
Root Cause / Culprit
Lighthouse identifies body.antialiased > main#main-content > section.mx-auto (the FAQ and CTA sections) as shifting by over 1,000px.
In app/(tools)/invoice-generator/InvoiceGeneratorClient.tsx:
- The client component initializes
const [current, setCurrent] = useState<Invoice | null>(null);. - During SSR and initial client render when
current === null, it renders a small placeholder card:<section className="mx-auto max-w-7xl w-full px-4 sm:px-6 pb-8"> <div className="card p-10 text-center text-[var(--fg-muted)] text-[13px]">Loading…</div> </section> - In
useEffect, it reads localStorage and callssetCurrent(...). - Once
currentis populated, the full toolbar, two-column editor form, and live preview are inserted into the DOM, pushing the FAQ and CTA sections down and triggering a large layout shift score (0.554 desktop, 0.465 mobile).
Concrete Next Step
- Refactor
InvoiceGeneratorClient.tsxso that initial render does not collapse into a small placeholder card. - Initialize default invoice state or render a layout-preserving skeleton that matches the dimensions of the toolbar, editor, and preview grids during SSR and before hydration.
- Re-run Lighthouse mobile and desktop audits to verify median CLS is ≤ 0.1.
- 主要语言
- TypeScript
- 星标
- 1
- 派生
- 9
- 平均合并
- 9 小时 9 分钟
- 30 天内合并 PR
- 118
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
codercops/toolbelt 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 55/100
维护者通常 1 天内回复
-
JWT encoder signs payloads that aren't JSON objects, and the decoder then rejects them可能已有人在做 @MugdhoAI 于 1 天前认领。 未关闭bug good first issue hacktoberfest
codercops/toolbelt#253 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
JSON to YAML: control characters are written raw, so PyYAML and js-yaml can't read the output可能已有人在做 @anurag2787 于 1 天前认领。 未关闭bug good first issue hacktoberfest
codercops/toolbelt#234 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
JSON formatter: Escape for code gives broken Python when the text has a run of single quotes可能已有人在做 @anurag2787 于 1 天前认领。 未关闭bug good first issue hacktoberfest
codercops/toolbelt#233 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Add the URL encoder to the README, the home share card and package.json可能已有人在做 @Abhishek764 于 4 天前认领。 未关闭documentation good first issue hacktoberfest
codercops/toolbelt#153 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 codercops/toolbelt 的全部 Issue
相似的 Issue
-
createAI: the ai peer range allows ai@6, which the provider cannot work with可能已有人在做 @akhil9tiet 今天认领。 未关闭bug
难度 1/5 1 小时以内 新手友好度 83/100
cloudflare/agents#2690 · 3 条评论 ·
维护者通常 1 天内回复
-
[fullsend] E2E: theme — global-header ignores app.branding.fullLogo (RHDHBUGS-3670)可能已有人在做 @fullsend-ai-coder 今天认领。 未关闭e2e-failure ready-to-code
难度 1/5 1 小时以内 新手友好度 78/100
redhat-developer/rhdh-plugin-export-overlays#4503 · 1 条评论 ·
维护者通常 1 天内回复
-
needs triage 📥
难度 1/5 1 小时以内 新手友好度 86/100
ethereum/ethereum-org-website#19601 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
cloudscape-design/components#5184 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
agilepathway/label-checker#805 ·
维护者通常 1 天内回复