-
-
Notifications
You must be signed in to change notification settings - Fork 318
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: multiple select none current panel should not trigger change #896
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough本次更改主要集中在 Changes
Assessment against linked issues
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint (1.23.1)
src/PickerInput/SinglePicker.tsxOops! Something went wrong! :( ESLint: 8.57.1 Error: Cannot read config file: /.eslintrc.js
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #896 +/- ##
=======================================
Coverage 95.46% 95.46%
=======================================
Files 64 64
Lines 2732 2734 +2
Branches 769 742 -27
=======================================
+ Hits 2608 2610 +2
Misses 121 121
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
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
🧹 Outside diff range and nitpick comments (3)
tests/multiple.spec.tsx (3)
171-174
: 建议增加年份面板可见性的断言在选择年份之前,建议先验证年份面板是否正确显示。
建议添加如下断言:
fireEvent.click(document.querySelector('.rc-picker-year-btn')); + expect(document.querySelector('.rc-picker-year-panel')).toBeTruthy(); selectCell(1998);
176-180
: 建议增加月份面板可见性的断言类似地,在选择月份之前,建议先验证月份面板是否正确显示。
建议添加如下断言:
// Select Month + expect(document.querySelector('.rc-picker-month-panel')).toBeTruthy(); selectCell('Oct');
184-188
: 验证回调参数的完整性
onCalendarChange
的回调参数验证可以更详细一些,建议检查完整的日期格式。建议修改为:
expect(onCalendarChange).toHaveBeenCalledWith( - expect.anything(), - ['1998-10-23'], - expect.anything(), + expect.arrayContaining([expect.any(Date)]), + ['1998-10-23'], + { source: 'date' } );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
src/PickerInput/SinglePicker.tsx
(1 hunks)tests/multiple.spec.tsx
(1 hunks)
🔇 Additional comments (3)
tests/multiple.spec.tsx (1)
159-193
: 测试用例完整地覆盖了年份面板选择的场景
测试用例通过以下步骤验证了多选模式下的选择行为:
- 打开年份面板并选择年份
- 选择月份
- 选择具体日期
- 确认选择
验证要点:
- 选择年份和月份时不会触发
onChange
和onCalendarChange
- 只有在选择具体日期时才会触发
onCalendarChange
- 点击确认按钮后才会触发
onChange
这个测试用例很好地覆盖了 PR #51721 中报告的问题。
src/PickerInput/SinglePicker.tsx (2)
444-447
: 优化了多选模式下的面板选择逻辑
这个条件判断很好地解决了多选模式下中间面板(年份/月份)选择触发值变更的问题。通过确保只有在最终面板(与picker类型匹配)选择时才更新值,避免了不必要的状态更新。
444-447
: 建议验证信息对象清理的一致性
代码中清理了传递给回调的info对象中的range属性,这是个好的实践。建议验证其他类似回调中是否也需要同样的清理操作,以保持代码一致性。
✅ Verification successful
Let me gather more context about the info object handling patterns.
Let me check for any other similar cleanup patterns in the codebase.
Let me try one final check to understand the full context of info object usage.
清理info对象的操作是合理且一致的
根据代码分析,info对象的清理操作仅在SinglePicker组件中出现,且只在特定场景(将panel模式的数据传递给外部回调时)需要清理range属性。这是一个局部性的数据清理需求,不需要在其他地方实施相同的清理模式。当前的实现是恰当且一致的。
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查其他地方是否有类似的info对象处理模式
rg "delete \w+\.range" --type ts
Length of output: 163
Script:
#!/bin/bash
# Search for info object handling patterns in SinglePicker.tsx
rg "info\." -A 5 -B 5 src/PickerInput/SinglePicker.tsx
# Search for similar patterns in other picker-related files
fd "Picker" --type f --exec rg "info\." -A 5 -B 5 {}
Length of output: 1929
Script:
#!/bin/bash
# Search for similar cleanup patterns with object properties
rg "const clean" -A 5 -B 5 --type ts
# Search for BaseInfo type definition
ast-grep --pattern 'type BaseInfo = {
$$$
}'
Length of output: 782
Script:
#!/bin/bash
# Search for all info object type definitions and interfaces
ast-grep --pattern 'interface $_ {
$$$
info: $_
$$$
}'
# Search for all onPickerValueChange implementations
ast-grep --pattern 'onPickerValueChange($$$) {
$$$
}'
Length of output: 120
fix ant-design/ant-design#51721
Summary by CodeRabbit
新功能
测试