Skip to content

fix: handle empty covers and zero-valued close icons - #534

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

说明

  • 按配置结构识别 preview cover,修复 cover=null、空配置和 coverNode 为零值或空值时的异常。
  • 保留 closeIcon={0};继续支持 true 使用默认图标、false/null 隐藏关闭按钮。
  • 补充空封面、零值、元素/数组/Portal 封面以及关闭图标测试。

验证

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

关联 ant-design/ant-design#59193

Summary by CodeRabbit

  • Bug 修复
    • 修正图片封面内容的识别方式,并在未提供有效无障碍标签时使用替代文本。
    • 修正预览关闭按钮的图标显示:无法渲染的自定义图标将回退为默认图标。

@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: b1f00e7d-cdb2-477b-99a4-df9f911576cf

📥 Commits

Reviewing files that changed from the base of the PR and between 4cbfa08 and 76e3d1c.

📒 Files selected for processing (3)
  • src/Image.tsx
  • src/Preview/index.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.


Walkthrough

本次调整封面对象的配置识别、预览状态下的 aria-label 回退,以及关闭图标的 React 可渲染性判断。新增测试覆盖封面值和关闭图标的渲染结果。

Changes

渲染值处理

Layer / File(s) Summary
封面配置与预览标签
src/Image.tsx, tests/renderability.test.tsx
封面对象按 coverNode 或 placement 属性识别为配置;普通原型的空对象也识别为配置。配置的位置默认使用 center。预览状态下,aria-label 为 null 或 undefined 时回退到 alt。测试覆盖基本值、元素、数组和 portal。
关闭图标渲染
src/Preview/index.tsx, tests/renderability.test.tsx
仅当 closeIcon 不是 true 且可由 React 渲染时,才将其用作自定义图标,否则使用默认图标。测试覆盖按钮显示和图标内容。

Priority: ➖ Normal

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

Change: Bug fix

Suggested reviewers: afc163

Merge Risk: ⚪ Minimal · up to 76e3d

No actionable issue is established for the cover, preview-label, or close-icon changes; the PR is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:处理空封面,并保留零值关闭图标。标题简洁、明确,且与代码变更和 PR 目标一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
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 💡 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.26%. Comparing base (4cbfa08) to head (76e3d1c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #534   +/-   ##
=======================================
  Coverage   99.26%   99.26%           
=======================================
  Files          17       17           
  Lines         543      546    +3     
  Branches      167      169    +2     
=======================================
+ Hits          539      542    +3     
  Misses          4        4           

☔ 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