Skip to content

fix: preserve zero-valued step content and icon styles - #399

Merged
yoyo837 merged 2 commits into
react-component:masterfrom
QDyanbing:fix-react-node-guards
Nov 24, 2026
Merged

yoyo837 merged 2 commits into
react-component:masterfrom
QDyanbing:fix-react-node-guards

Conversation

@QDyanbing

@QDyanbing QDyanbing commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

说明

  • 保留 itemRender 返回的 0,避免将有效内容替换成 null。
  • icon={0} 正确标记自定义图标样式,补充零值与空值回归测试。

验证

  • npm test -- --runInBand(30 项通过)
  • npm run tsc
  • 改动源码 ESLint 检查通过。

关联 ant-design/ant-design#59193

Summary by CodeRabbit

  • Bug 修复
    • 优化步骤项对自定义图标和渲染内容的处理,确保数字 0 可以正常显示;无效或空内容不会生成步骤内容。

@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

@QDyanbing is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6453c3c7-139d-4f28-acd3-e1ff2ebacf4e
Commits

Reviewing files that changed from the base of the PR and between a697d2e and 45b8894.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Step.tsx 使用 isReactRenderable 判断 icon 和 itemRender 的返回值,并据此设置自定义图标类和步骤节点。新增测试覆盖数值、空值及布尔值等渲染情况。

Changes

步骤渲染值判断

Layer / File(s) Summary
渲染值判断与测试
src/Step.tsx, tests/renderability.test.tsx
Step.tsx 使用 isReactRenderable 判断 icon 和 itemRender 的返回值。测试验证 itemRender 返回 0 时保留文本,返回 false、null、undefined 或空字符串时步骤内容为空,并验证 icon 为 0 时添加自定义样式类。

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · previous review a697d

Zero-valued step content is preserved and the requested icon styling is applied; no concrete user-facing issue is established that should block merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)

Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:保留 itemRender 返回的 0,并修复 icon={0} 的自定义图标样式判断。标题简洁且与代码和测试变更一致。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Fix failing CI checks

  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

兔子蹦到步骤旁,
看见零字亮晶晶。
图标虽小也显现,
空值退场不留影。
新测试本上画个圈,
月光下把萝卜分。

ℹ️ Recent review info

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 1ff98441-7f86-46f5-9da2-c5abfef7afde

📥 Commits

Reviewing files that changed from the base of the PR and between 400f7cf and a697d2e.

📒 Files selected for processing (2)

  • src/Step.tsx
  • tests/renderability.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (d1060e2) to head (45b8894).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #399   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines           97        98    +1     
  Branches        36        37    +1     
=========================================
+ Hits            97        98    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zombieJ

zombieJ commented Nov 23, 2026

Copy link
Copy Markdown
Member

来自 Code Review Skill

结论先行

⚠️ 有条件合并 — Steps #399 修复了 itemRender 丢掉 0 的问题。Ant Design 升级此依赖时,需要同步修复图标内容的判断,否则 icon={0} 会让默认图标套上自定义样式。GitHub Actions 的 Lint、类型检查、构建和单测均通过。Vercel 预览因授权未通过,本次未做浏览器验证。 CI 日志

主要变更内容

步骤内容与图标样式

itemRender 返回 0 时保留该值,icon={0} 时添加自定义图标类。新增一个测试文件,覆盖这两种情况及空值返回。

- [`${itemCls}-custom`]: icon,
+ [`${itemCls}-custom`]: isReactRenderable(icon),

- stepNode = (itemRender(stepNode, renderInfo) || null) as React.ReactElement;
+ const renderedNode = itemRender(stepNode, renderInfo);
+ stepNode = isReactRenderable(renderedNode) ? renderedNode : null;

问题清单(按重要程度排序)

🔴 高优先级(阻塞合并)

无。

🟡 中优先级(建议修复)

  • Ant Design 升级后,默认图标会套用自定义样式 — src/Step.tsx:129
    例如第一个步骤传入 icon={0},Ant Design 的 if (isDot || icon) 仍会回退到默认编号 1。本 PR 同时给该步骤加上 -item-custom,使默认图标失去背景和边框。建议在 Ant Design 的依赖升级 PR 中同步改用 isReactRenderable(icon),并补一个 items={[{ icon: 0 }]} 的回归测试,断言图标内容为 0。 样式类变更 · Ant Design 图标渲染 · 自定义图标样式

🟢 低优先级(可选改进)

无。

@yoyo837

yoyo837 commented Nov 24, 2026

Copy link
Copy Markdown
Member

这个改动应该必须发minor了,antd有代码需要适配。

@yoyo837

yoyo837 commented Nov 24, 2026

Copy link
Copy Markdown
Member

这个改动应该必须发minor了,antd有代码需要适配。

之前的效果算bug的话,就另说了。

@QDyanbing

Copy link
Copy Markdown
Contributor Author

minor

安全起见 minor

@yoyo837
yoyo837 merged commit 404d61e into react-component:master Nov 24, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants