fix: do not render value in combobox mode with custom input#1213
fix: do not render value in combobox mode with custom input#1213
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary of ChangesHello @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 resolves a visual bug in the Highlights
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
Walkthrough修改SelectInput组件中SingleContent的值渲染逻辑,在combobox模式下提供自定义输入框时,条件性地禁用值的显示。同时添加测试用例验证此场景下的预期行为。 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1213 +/- ##
=======================================
Coverage 99.43% 99.43%
=======================================
Files 31 31
Lines 1236 1239 +3
Branches 444 449 +5
=======================================
+ Hits 1229 1232 +3
Misses 7 7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the issue of duplicate value rendering in combobox mode when a custom input is used. The fix is implemented cleanly by introducing a shouldRenderValue flag in SingleContent.tsx that prevents the value from being rendered separately in this specific scenario. The addition of a new test case in Combobox.test.tsx is excellent, as it thoroughly validates the corrected behavior and ensures there are no regressions. The changes are well-targeted and improve the component's behavior as intended. Great work!
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/SelectInput/Content/SingleContent.tsx (1)
66-104: 可选:禁用值渲染时同步去掉content-has-value类名当前在自定义 input 且
shouldRenderValue为 false 时,showHasValueCls仍可能添加,可能触发与值展示相关的样式残留。可以把该 class 与shouldRenderValue绑定。♻️ 建议修改
- const showHasValueCls = - displayValue && - displayValue.label !== null && - displayValue.label !== undefined && - String(displayValue.label).trim() !== ''; - - // Render value - // Only render value when not using custom input in combobox mode - const shouldRenderValue = !(combobox && components?.input); + // Only render value when not using custom input in combobox mode + const shouldRenderValue = !(combobox && components?.input); + const showHasValueCls = + shouldRenderValue && + displayValue && + displayValue.label !== null && + displayValue.label !== undefined && + String(displayValue.label).trim() !== '';🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/SelectInput/Content/SingleContent.tsx` around lines 66 - 104, The class flag showHasValueCls should not be applied when the value isn't being rendered (shouldRenderValue is false); update the className construction in the component (where `${prefixCls}-content` is built) to combine showHasValueCls with shouldRenderValue (e.g., only include `${prefixCls}-content-has-value` when both showHasValueCls and shouldRenderValue are true) so that when renderValue is null you won't leave the stale `content-has-value` class affecting styles; adjust the logic around showHasValueCls / shouldRenderValue where renderValue is computed to ensure the class is conditionally added.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/SelectInput/Content/SingleContent.tsx`:
- Around line 66-104: The class flag showHasValueCls should not be applied when
the value isn't being rendered (shouldRenderValue is false); update the
className construction in the component (where `${prefixCls}-content` is built)
to combine showHasValueCls with shouldRenderValue (e.g., only include
`${prefixCls}-content-has-value` when both showHasValueCls and shouldRenderValue
are true) so that when renderValue is null you won't leave the stale
`content-has-value` class affecting styles; adjust the logic around
showHasValueCls / shouldRenderValue where renderValue is computed to ensure the
class is conditionally added.
fix ant-design/ant-design#56932
fix ant-design/ant-design#56948
close #1211
Summary by CodeRabbit
发布说明