Skip to content

Conversation

@zombieJ
Copy link
Member

@zombieJ zombieJ commented Jan 30, 2026

ant-design/ant-design#56808 (comment)

Summary by CodeRabbit

发布说明

  • 新功能

    • 增强了选择输入的选项样式化渲染,支持自定义样式和标题属性。
    • 改进了占位符显示逻辑。
  • Bug 修复

    • 优化了选择值的标题属性处理链(选项数据→显示值→根标题)。
    • 修复了搜索值控制逻辑和输入框最大长度限制。
  • 测试

    • 重构了测试工具函数以提高代码可维护性。

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 30, 2026

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

Project Deployment Actions Updated (UTC)
select Ready Ready Preview, Comment Jan 30, 2026 7:56am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

概述

通过提取选项样式和标题数据,重构单选内容组件的渲染逻辑;扩展输入控制以支持组合框模式;统一测试工具的内容节点查询路径以支持多种DOM结构。

变更

内容组/文件(s) 总结
单选内容组件重构
src/SelectInput/Content/SingleContent.tsx
提取选项的className、style、title和hasOptionStyle标志,替代内联的optionProps构造;新增条件渲染逻辑以处理有样式的div或纯文本显示;实现title的级联查询路径;扩展Input为受控组件,支持maxLength和改进onChange处理。
测试工具函数调整
tests/utils/common.ts
扩展findSelection的内容节点查询:先查询.rc-select-content-value,回退到.rc-select-content;整理keyDown函数签名格式。
测试用例更新
tests/Select.test.tsx, tests/placeholder.test.tsx
将直接DOM查询.rc-select-content-value替换为findSelection(container)辅助函数,统一获取选中值文本和title属性的方式。

代码审查工作量评估

🎯 3 (中等) | ⏱️ ~20 分钟

可能相关的PR

建议审阅者

  • afc163

诗歌

🐰 选项数据妙分离,样式标题各其位,
内容渲染添新彩,回退查询聚众智,
测试路径统一归,掌声雷动庆升级!

🚥 Pre-merge checks | ✅ 2 | ❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确反映了变更的主要内容,即简化SelectSingle组件的结构和逻辑,涉及重构props提取、渲染逻辑和样式处理。

✏️ 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 simplify

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


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.

@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 refactors the internal rendering logic for the single selection mode of the Select component. The primary goal is to simplify the DOM structure and improve efficiency by conditionally rendering wrapper elements only when necessary for custom styling. This change streamlines the component's internal workings, leading to a cleaner and potentially more performant output for common use cases, while ensuring existing functionalities and custom styling capabilities are maintained through careful property handling and updated test infrastructure.

Highlights

  • Refactored Single Select Content Rendering: The logic for rendering the selected value in SingleContent.tsx has been simplified. It now conditionally renders a wrapper div for the label only when custom styles or classes are explicitly applied to the option, otherwise, the label is rendered directly.
  • Optimized DOM Structure: For single select options without custom className or style properties, the DOM structure is now flatter. The title attribute, if present, is moved to the parent content div, reducing unnecessary nested elements and potentially improving rendering performance.
  • Updated Test Infrastructure: The findSelection utility function in tests/utils/common.ts was enhanced to correctly locate the selected element, accommodating the new conditional rendering logic. Corresponding test files (Select.test.tsx, placeholder.test.tsx) and snapshots (Select.test.tsx.snap) were updated to reflect these structural adjustments.

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

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.

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 refactors the rendering logic for single-value Select components to simplify the structure. The change avoids rendering an unnecessary wrapper div when the selected option has no custom styling, which is a good simplification and minor performance optimization. The test files, including snapshots, have been updated accordingly to reflect these structural changes. The refactoring is well-executed and improves code clarity. The changes look solid.

@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.42%. Comparing base (b23bfff) to head (5662d7f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1195   +/-   ##
=======================================
  Coverage   99.42%   99.42%           
=======================================
  Files          31       31           
  Lines        1224     1226    +2     
  Branches      414      438   +24     
=======================================
+ Hits         1217     1219    +2     
  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 e8d6c5a into master Jan 30, 2026
12 checks passed
@zombieJ zombieJ deleted the simplify branch January 30, 2026 08:09
@coderabbitai coderabbitai bot mentioned this pull request Jan 30, 2026
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