Skip to content

fix: handle number 0 as valid label in SingleContent#1208

Merged
zombieJ merged 1 commit intomasterfrom
fix/number-zero-value-display
Feb 13, 2026
Merged

fix: handle number 0 as valid label in SingleContent#1208
zombieJ merged 1 commit intomasterfrom
fix/number-zero-value-display

Conversation

@zombieJ
Copy link
Member

@zombieJ zombieJ commented Feb 13, 2026

  • Fix logic bug where number 0 was incorrectly excluded from has-value className
  • Update condition to explicitly check null, undefined, and empty string
  • Add test case for number 0 value display

Summary by CodeRabbit

Bug Fixes

  • 修复了 Select 组件在处理数值 0 时的边界情况问题。现在数值 0 会被正确识别为有效值,而不是被误处理为空值。

Tests

  • 添加了测试用例以验证 Select 组件对数值 0 的正确处理,确保该边界情况得到妥善处理。

- Fix logic bug where number 0 was incorrectly excluded from has-value className
- Update condition to explicitly check null, undefined, and empty string
- Add test case for number 0 value display
@vercel
Copy link

vercel bot commented Feb 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
select Ready Ready Preview, Comment Feb 13, 2026 3:14am

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @zombieJ, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a specific bug in the SelectInput component where a selected value of 0 was not correctly identified as a valid input, leading to incorrect styling. The changes ensure that the component now properly applies the has-value CSS class when 0 is selected, improving the visual consistency and correctness of the UI.

Highlights

  • Bug Fix: Corrected a logic error in SingleContent.tsx where the number 0 was not recognized as a valid label, preventing the has-value CSS class from being applied.
  • Logic Update: Modified the condition for applying the has-value class to explicitly check for null, undefined, and empty string, ensuring 0 is now correctly handled.
  • Test Coverage: Introduced a new test case in Select.test.tsx to specifically verify the correct behavior when 0 is used as a selected value.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/SelectInput/Content/SingleContent.tsx
    • Modified the conditional logic for applying the rc-select-content-has-value class.
    • Expanded the displayValue.label check to explicitly exclude null, undefined, and empty string.
  • tests/Select.test.tsx
    • Added a new test case to assert that the rc-select-content-has-value class is present when the Select component's value is 0.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 13, 2026

演练说明

该PR修改了SingleContent.tsx中displayValue标签的条件判断逻辑,从简单的真值检查改为更严格的非空检查,并在测试文件中添加了验证数值0被正确识别为有值的两个测试用例。

变更内容

内聚性 / 文件 摘要
核心逻辑修改
src/SelectInput/Content/SingleContent.tsx
增强了displayValue标签存在性的条件判断,从truthy检查升级为严格的非null、非undefined、非空字符串检查,确保-content-has-value class应用更加精准。
测试覆盖
tests/Select.test.tsx
添加两个测试用例,验证数值0作为Select组件的值时,-content-has-value className被正确应用,确保0不被误判为空值。

预期代码审查工作量

🎯 2 (Simple) | ⏱️ ~10 分钟

可能相关的PR

诗歌

🐰 数字零也有价值哦,
不被空值冷落,
严格判断守护着,
每个状态都闪耀✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ⚠️ Unable to check for merge conflicts: Stream setup permanently failed: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰准确地总结了主要变更:修复数字0作为有效标签的处理问题,与changeset中的核心改动完全相关。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/number-zero-value-display
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch fix/number-zero-value-display
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
src/SelectInput/Content/SingleContent.tsx (1)

91-95: 修复正确,可选:条件可以简化。

使用 != null(非严格相等)可以同时覆盖 nullundefined,减少一个条件判断:

♻️ 可选简化
-          displayValue &&
-            displayValue.label !== null &&
-            displayValue.label !== undefined &&
-            displayValue.label !== '' &&
-            `${prefixCls}-content-has-value`,
+          displayValue &&
+            displayValue.label != null &&
+            displayValue.label !== '' &&
+            `${prefixCls}-content-has-value`,

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 and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a bug where a label with the value 0 was not being displayed correctly. The change adjusts the condition to explicitly check for null, undefined, and empty strings, ensuring 0 is treated as a valid value, and a corresponding test case has been added. No security vulnerabilities were found. My feedback includes a suggestion to make the condition more concise.

Comment on lines +92 to +94
displayValue.label !== null &&
displayValue.label !== undefined &&
displayValue.label !== '' &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The condition to check for null and undefined can be simplified. Using the loose inequality operator != null checks for both null and undefined and is a common JavaScript idiom for this purpose. This makes the code more concise.

Suggested change
displayValue.label !== null &&
displayValue.label !== undefined &&
displayValue.label !== '' &&
displayValue.label != null && displayValue.label !== '' &&

@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.43%. Comparing base (89c8e26) to head (01305bd).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1208   +/-   ##
=======================================
  Coverage   99.43%   99.43%           
=======================================
  Files          31       31           
  Lines        1230     1234    +4     
  Branches      441      445    +4     
=======================================
+ Hits         1223     1227    +4     
  Misses          7        7           

☔ View full report in Codecov by Sentry.
📢 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 merged commit 1ca8483 into master Feb 13, 2026
12 checks passed
@zombieJ zombieJ deleted the fix/number-zero-value-display branch February 13, 2026 03:28
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