-
Notifications
You must be signed in to change notification settings - Fork 267
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: 受控模式下返回的selectedOptions进行校验处理 #2951
Conversation
变更概览演练这个变更修改了 变更
可能相关的 PR
建议标签
建议审阅者
诗歌
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (1)
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 @@
## next #2951 +/- ##
==========================================
+ Coverage 84.02% 84.20% +0.18%
==========================================
Files 220 267 +47
Lines 17917 18125 +208
Branches 2628 2671 +43
==========================================
+ Hits 15055 15263 +208
Misses 2857 2857
Partials 5 5 ☔ View full report in Codecov by Sentry. |
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/packages/datepicker/datepicker.taro.tsx
(1 hunks)src/packages/datepicker/datepicker.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (1)
src/packages/datepicker/datepicker.taro.tsx (1)
273-286
: 代码变更与 Web 版本保持一致!Taro 版本的修复与 Web 版本完全一致,这确保了在不同环境下组件行为的一致性。
|
||
if ( | ||
selectedOptions.length >= 2 && | ||
(rangeType === 'date' || | ||
rangeType === 'month-day' || | ||
rangeType === 'datetime') | ||
) { | ||
const dayOption = formatOption('day', day) | ||
if (rangeType === 'month-day') { | ||
selectedOptions[1] = dayOption | ||
} else { | ||
selectedOptions[2] = dayOption | ||
} | ||
} |
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.
💡 Codebase verification
需要补充 selectedOptions 数组更新逻辑的测试用例!
当前测试文件缺少对新增逻辑的覆盖。建议添加以下测试场景:
- 验证 'date' 类型时 selectedOptions[2] 的日期更新
- 验证 'month-day' 类型时 selectedOptions[1] 的日期更新
- 验证 'datetime' 类型时 selectedOptions[2] 的日期更新
- 验证当 selectedOptions.length < 2 时的边界情况
示例测试用例位置:src/packages/datepicker/__test__/datepicker.spec.tsx
🔗 Analysis chain
修复了 selectedOptions 的校验和更新逻辑!
代码变更正确地处理了不同日期类型下 selectedOptions 数组中日期选项的更新。这个修复确保了在受控模式下返回的选项数据的准确性。
建议:
- 为这个修复添加单元测试,覆盖以下场景:
- 'date' 类型的日期选择
- 'month-day' 类型的日期选择
- 'datetime' 类型的日期选择
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查是否存在相关的测试用例
rg -l "test.*date.*selectedOptions|test.*month-day.*selectedOptions|test.*datetime.*selectedOptions" --type ts --type tsx
Length of output: 151
Script:
#!/bin/bash
# Search for test files related to datepicker
echo "=== Searching in .ts files ==="
rg -l "test.*datepicker.*selectedOptions" --type ts
echo "=== Looking for datepicker test files ==="
fd "datepicker.*(test|spec)\.(ts|tsx)$"
echo "=== Searching content in potential test files ==="
rg "selectedOptions.*date|selectedOptions.*month-day|selectedOptions.*datetime" --type ts -A 5
Length of output: 518
Script:
#!/bin/bash
# View the content of the test file
echo "=== Datepicker test file content ==="
cat src/packages/datepicker/__test__/datepicker.spec.tsx
Length of output: 4978
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.
需要关注下 datehour 的情况
|
#2924
Summary by CodeRabbit