-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve to not treat as a valid option when the value is null. #564
fix: improve to not treat as a valid option when the value is null. #564
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough此次修改涉及 Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
This reverts commit 0dd12df.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/TreeSelect.tsx (1 hunks)
- tests/Select.multiple.spec.js (1 hunks)
Additional comments not posted (2)
tests/Select.multiple.spec.js (1)
315-349
: 新增测试用例验证null
值处理新增的测试用例验证了当
value
设置为null
时的行为,确保没有选中的项目,并且占位符正确显示。代码更改已批准。
src/TreeSelect.tsx (1)
393-393
: 更新internalValue
处理逻辑更新后的逻辑确保当
internalValue
为null
时,传入一个空数组[]
,避免潜在错误。代码更改已批准。
改完后是一个什么效果? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #564 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 16 16
Lines 516 516
Branches 150 141 -9
=========================================
Hits 516 516 ☔ View full report in Codecov by Sentry. |
it('should not omit value when value is null', () => { | ||
const { container } = render( | ||
<TreeSelect | ||
value={null} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value={[null]}
value={[null, null]}
value={['child1', null]}
的 UI 表现分别是什么样的?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你说的这3种形式,都属于同一种case,表明已选 value 为 null 的字段。 (这点和 select 的规则一样)
但应该不会出现第二种吧,表示选择了两个 null,
在 options 种允许 value 为 null 的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
具体 UI 表现如何呢,本次改动是否有影响?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
具体 UI 表现如何呢,本次改动是否有影响?
我 debug 枚举一下看看,(应该没啥影响)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe fix: ant-design/ant-design#50578 (comment)
Summary by CodeRabbit
新功能
TreeSelect
组件的逻辑,以确保在处理null
值时不会发生错误。测试
TreeSelect
组件在value
属性为null
时的行为,确保正确处理并显示占位符。