Skip to content

fix: preserve zero-valued item and expand icons - #897

Open
QDyanbing wants to merge 1 commit into
react-component:masterfrom
QDyanbing:fix-react-node-guards
Open

QDyanbing wants to merge 1 commit into
react-component:masterfrom
QDyanbing:fix-react-node-guards

Conversation

@QDyanbing

@QDyanbing QDyanbing commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

说明

  • 保留全局与局部的 itemIcon={0},局部零值图标可以正确覆盖全局图标。
  • 共享 Icon 渲染支持 expandIcon={0},保留现有 false/null 隐藏约定,并补充回归测试。

验证

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

关联 ant-design/ant-design#59193

Summary by CodeRabbit

  • Bug 修复
    • 修复菜单图标值为 0 时无法正确显示的问题。
    • 改进不可渲染的图标值的回退显示;展开图标为 0、false 或 null 时,子菜单标题与箭头显示保持正确。

@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 →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: e7429fdd-575e-4800-9367-8058d2fb4e24

📥 Commits

Reviewing files that changed from the base of the PR and between 8dfdef4 and 0bca37a.

📒 Files selected for processing (3)
  • src/Icon.tsx
  • src/MenuItem.tsx
  • tests/renderability.test.tsx

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


Walkthrough

Icon 和 MenuItem 现在使用 isReactRenderable 判断图标是否可渲染。新增测试覆盖全局及单项 itemIcon,以及内联子菜单的 expandIcon。

Changes

菜单图标渲染

Layer / File(s) Summary
图标渲染判断与测试
src/Icon.tsx, src/MenuItem.tsx, tests/renderability.test.tsx
Icon 根据 isReactRenderable 判断是否返回图标节点,否则回退到子节点或 null。MenuItem 在单项图标不可渲染时回退到上下文图标。测试覆盖全局及单项 itemIcon={0},以及 expandIcon 为 0、false 或 null 时的标题文本和箭头元素。

Priority: ➖ Normal

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 0bca3

Zero-valued icons are preserved, and the local-over-global behavior is covered by a regression test. The change is mergeable after normal checks.

🚥 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 3 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 标题准确概括了主要变更:保留值为 0 的 item 和 expand 图标。标题简洁、明确,并与代码修改和回归测试一致。
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR

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

兔子捧着小图标,
零也能在菜单中显现。
可渲染时,图标登场,
不可渲染时,回退有序。
测试轻敲代码门,
月光下,菜单安静发亮。

Comment @coderabbitai help to get the list of available commands.

@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 99.72%. Comparing base (8dfdef4) to head (0bca37a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #897   +/-   ##
=======================================
  Coverage   99.72%   99.72%           
=======================================
  Files          26       26           
  Lines         736      736           
  Branches      204      204           
=======================================
  Hits          734      734           
  Misses          2        2           

☔ 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.

This branch has not been deployed

No deployments
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.

1 participant