Skip to content

fix: preserve zero-valued dropdown content and icons - #1254

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

说明

  • notFoundContent={0} 可以打开并显示空列表;menuItemSelectedIcon={0} 仅在选中项中显示。
  • 统一选项 label 与单选值展示的可渲染/非空判断,保留现有空白字符串处理。
  • 补充空列表、选中图标及零值选项标签测试。

验证

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

关联 ant-design/ant-design#59193

Summary by CodeRabbit

  • 问题修复

    • 修正下拉空状态内容、选择图标和选项标签的可渲染性判断,0 等有效内容可正常显示。
    • 更新单选值和输入内容的空值判断;标签为 0 等非空值时,显示内容不再被清空。
    • 空选项且空状态内容不可渲染时,下拉框仍不会打开。
  • 测试

    • 新增测试,覆盖空状态内容、零值选择图标及零值标签在下拉项和已选值区域的显示。

@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

@QDyanbing is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

本次更新调整选择器对可渲染内容和空值的判断,涉及下拉空状态、选项图标、选项标签及单选值显示。新增测试覆盖零值内容。

Changes

可渲染内容处理

Layer / File(s) Summary
下拉空状态判断
src/BaseSelect/index.tsx, tests/renderability.test.tsx
空选项时,组件使用 isReactRenderable 判断 notFoundContent 是否可渲染。测试验证 notFoundContent={0} 显示为 0。
选项与单选值显示
src/OptionList.tsx, src/Select.tsx, src/SelectInput/Content/SingleContent.tsx, tests/renderability.test.tsx
选项图标和标签改用可渲染性判断。单选值显示和内容区域使用 isNonNullable 判断标签是否非空。测试验证零值图标仅显示于选中项,并验证零值标签显示在选项和已选值区域。

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

Change: Bug fix

Suggested reviewers: zombiej, yoyo837

Merge Risk: Minimal · up to adfc2

This change makes numeric zero render correctly in dropdown empty content, selected icons and option labels. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题“fix: preserve zero-valued dropdown content and icons”与变更集相符。变更涉及 BaseSelect、OptionList、Select 和 SingleContent 中对数字 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

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • 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

  • 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: 9ef8a4d8-7dd8-45fe-b6fc-a5c38ab660a8
Commits

Reviewing files that changed from the base of the PR and between ae0f936 and adfc22a.

Files selected for processing: 2

  • src/BaseSelect/index.tsx
  • src/OptionList.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.

@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.46%. Comparing base (bc783bb) to head (adfc22a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1254      +/-   ##
==========================================
- Coverage   99.46%   99.46%   -0.01%     
==========================================
  Files          31       31              
  Lines        1307     1304       -3     
  Branches      479      476       -3     
==========================================
- Hits         1300     1297       -3     
  Misses          7        7              

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

@yoyo837

yoyo837 commented Nov 24, 2026

Copy link
Copy Markdown
Member

冲突了

@yoyo837
yoyo837 merged commit dddd067 into react-component:master Nov 24, 2026
11 of 12 checks passed
@QDyanbing
QDyanbing deleted the fix-react-node-guards branch November 24, 2026 01:48
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.

2 participants