Skip to content
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: the RangePicker sets disabledDate, the date cannot be modified #888

Merged
merged 2 commits into from
Nov 4, 2024

Conversation

Zyf665
Copy link
Contributor

@Zyf665 Zyf665 commented Nov 3, 2024

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ❓ Other (about what?)

🔗 Related Issues

fix ant-design/ant-design#51402

💡 Background and Solution

  • In RangePicker component, when the start date is disabled (disabled[0] = true)
  • And the initial value meets the disabledDate condition
  • The end date cannot be changed normally
    Solution:
    Don't check the value if it is disabled

📝 Change Log

Language Changelog
🇺🇸 English fix the RangePicker sets disabledDate, the date cannot be modified
🇨🇳 Chinese 修复当RangePicker设置disabledDate时,日期无法正常修改的问题

Summary by CodeRabbit

Summary by CodeRabbit

  • 新功能

    • 增强了日期范围选择器的日期验证逻辑,确保禁用的日期被正确处理。
  • 错误修复

    • 更新了测试用例,确保在选择禁用日期时不会触发 onChange 回调。
  • 测试

    • 增加了对禁用日期的检查,确保组件在选择无效日期时的行为符合预期。
    • 改进了测试结构,使其更易于理解和导航。

Copy link

vercel bot commented Nov 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
picker ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 4, 2024 7:30am

Copy link

coderabbitai bot commented Nov 3, 2024

Walkthrough

此次更改主要集中在 src/PickerInput/hooks/useRangeValue.ts 文件中的 useRangeValue 函数,增强了日期范围的验证逻辑。更新后的验证条件包括对禁用日期的检查。测试文件 tests/range.spec.tsx 也进行了修改,增加了新的测试用例以验证组件在处理禁用日期时的行为,并改进了测试的组织结构和覆盖范围。

Changes

文件路径 更改摘要
src/PickerInput/hooks/useRangeValue.ts 更新 useRangeValue 函数的日期验证逻辑,新增对禁用日期的检查。
tests/range.spec.tsx 增加测试用例以验证禁用日期的处理,改进测试结构和覆盖范围,确保组件在用户输入时的行为符合预期。

Assessment against linked issues

Objective Addressed Explanation
期望能够修改日期 (#51402)
确保禁用日期的处理符合预期

Possibly related PRs

  • feat: support prefix prop #884: 此PR增强了日期范围的验证逻辑,而相关PR引入了 prefix 属性到多个组件,包括 DayRangePicker,可能影响日期选择器中日期的显示和交互方式。

Suggested reviewers

  • zombieJ

Poem

在草地上跳跃的小兔,
日期选择真是个好处。
禁用日期不再烦恼,
测试覆盖全都到位,
让我们一起欢呼雀跃! 🐇🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b4a3dca and 17e849d.

📒 Files selected for processing (1)
  • tests/range.spec.tsx (3 hunks)
🔇 Additional comments (3)
tests/range.spec.tsx (3)

234-251: 测试用例验证了禁用起始日期的场景

测试用例验证了当起始日期被禁用时(disabled[0] = true),用户仍然可以修改结束日期。这与 PR 的目标一致,确保了修复后的行为符合预期。


252-269: 测试用例验证了禁用结束日期的场景

测试用例验证了当结束日期被禁用时(disabled[1] = true),用户仍然可以修改起始日期。这是一个很好的对称性测试,确保了组件在两种禁用场景下都能正常工作。


581-581: 验证了 tabIndex 属性的传递

测试确保 tabIndex 属性能够正确传递给输入框。这是一个重要的可访问性特性。


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.43%. Comparing base (281bf37) to head (17e849d).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #888   +/-   ##
=======================================
  Coverage   95.43%   95.43%           
=======================================
  Files          64       64           
  Lines        2719     2719           
  Branches      762      734   -28     
=======================================
  Hits         2595     2595           
  Misses        121      121           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zombieJ zombieJ merged commit 4724a58 into react-component:master Nov 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DatePicker组件设置了disabledDate后,没法修改日期了
2 participants