Add range info to disabledDate#989
Conversation
|
@QDyanbing is attempting to deploy a commit to the afc163's projects Team on Vercel. A member of the Team first needs to authorize it. |
Walkthrough本 PR 为 RangePicker 的 disabledDate/isInvalidateDate 回调新增 range('start'/'end')信息。interface.tsx 新增 BaseInfo 类型并合并进 DisabledDate。useInvalidate.ts 抽取 InvalidateDateInfo 类型。RangePicker.tsx 新增 isRangeInvalidateDate 包装函数并替换多处调用。useRangeDisabledDate.ts 调整索引推导逻辑。新增相关测试。 ChangesRange 感知的失效日期判断
Sequence Diagram(s)sequenceDiagram
participant User
participant RangePicker
participant isRangeInvalidateDate
participant disabledDate
User->>RangePicker: 打开面板并选择日期
RangePicker->>isRangeInvalidateDate: 校验日期(date, activeIndex)
isRangeInvalidateDate->>isRangeInvalidateDate: 计算 range('start'/'end')
isRangeInvalidateDate->>disabledDate: 调用disabledDate(date, {range, from, ...})
disabledDate-->>isRangeInvalidateDate: 返回是否禁用
isRangeInvalidateDate-->>RangePicker: 返回校验结果
RangePicker-->>User: 更新单元格/OK按钮状态
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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
src/PickerInput/RangePicker.tsxESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. src/PickerInput/hooks/useInvalidate.tsESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox. src/PickerInput/hooks/useRangeDisabledDate.tsESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.
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 #989 +/- ##
=======================================
Coverage 98.81% 98.81%
=======================================
Files 66 66
Lines 2698 2702 +4
Branches 749 752 +3
=======================================
+ Hits 2666 2670 +4
Misses 29 29
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for passing the active range ('start' or 'end') context to the disabledDate function within RangePicker. This is accomplished by defining a new BaseInfo interface, updating the DisabledDate type, and refactoring the useRangeDisabledDate and useInvalidate hooks to propagate the range information. Additionally, comprehensive unit tests have been added to validate this new behavior. Feedback on the changes suggests adjusting the property merging order in useRangeDisabledDate to ensure that any explicitly provided range in the info parameter is not silently overwritten.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/PickerInput/hooks/useInvalidate.ts (1)
39-42: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value可选:复用
info.range代替重复计算。此处仍用
info.activeIndex === 1本地推导range供disabledTime使用,而调用方(RangePicker.tsx中的isRangeInvalidateDate)已经通过BaseInfo把range计算好并合并进info。两者逻辑一致,非 bug,但可以直接用info.range消除重复推导逻辑,逻辑收敛更清晰。♻️ 可选简化
- const range = info && info.activeIndex === 1 ? 'end' : 'start'; + const range = info?.range ?? (info && info.activeIndex === 1 ? 'end' : 'start');🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/PickerInput/hooks/useInvalidate.ts` around lines 39 - 42, The range for disabledTime is being recomputed locally from info.activeIndex in useInvalidate, even though BaseInfo already carries info.range from RangePicker’s isRangeInvalidateDate flow. Update the useInvalidate logic to read the existing info.range when available and pass that through to showTime.disabledTime, keeping the fallback behavior aligned with the current active index handling in useInvalidate and its callers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/PickerInput/RangePicker.tsx`:
- Around line 337-344: The range wrapper in RangePicker’s isRangeInvalidateDate
path is dropping the `from` field, so `disabledDate` rules that rely on
`info.from` can disagree between OK-button disabling and panel cell disabling.
Update the `useEvent` callback for `isRangeInvalidateDate` and the related
`useInvalidate` call site so the forwarded `InvalidateDateInfo` includes the
current range start (`from`) alongside `activeIndex` and `range`, using the
existing `activeIndex`/`getActiveRange` logic to populate it consistently.
---
Nitpick comments:
In `@src/PickerInput/hooks/useInvalidate.ts`:
- Around line 39-42: The range for disabledTime is being recomputed locally from
info.activeIndex in useInvalidate, even though BaseInfo already carries
info.range from RangePicker’s isRangeInvalidateDate flow. Update the
useInvalidate logic to read the existing info.range when available and pass that
through to showTime.disabledTime, keeping the fallback behavior aligned with the
current active index handling in useInvalidate and its callers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 99ce5578-359f-491c-9285-5a75657bcb1a
📒 Files selected for processing (6)
src/PickerInput/RangePicker.tsxsrc/PickerInput/hooks/useInvalidate.tssrc/PickerInput/hooks/useRangeDisabledDate.tssrc/PickerInput/hooks/useRangeValue.tssrc/interface.tsxtests/new-range.spec.tsx
背景
处理 ant-design/ant-design#58569:RangePicker 的
disabledDate需要像disabledTime一样能够区分当前作用在 start 还是 end 字段。变更
DisabledDate的info增加range?: 'start' | 'end'。info.range,覆盖面板、输入校验和 OK 按钮禁用状态。disabledDate原有from语义,避免改变已有行为。info.range、OK 按钮禁用、from行为保持,以及仅作用于 end 字段的禁用场景。验证
npm run tscnpm test -- tests/new-range.spec.tsx tests/range.spec.tsx --runInBandSummary by CodeRabbit
新功能
Bug 修复