nextui icon indicating copy to clipboard operation
nextui copied to clipboard

Fix DatePicker Time Input

Open chirokas opened this issue 1 year ago • 5 comments

Closes #

📝 Description

Closing the Date Picker while the Month and Year Pickers are open causes the Time Input to disappear when reopened.

https://github.com/nextui-org/nextui/blob/1ba2d029a291f5d40cbf03f66107eb2ebed09066/packages/components/date-picker/src/date-picker.tsx#L41-L42

⛳️ Current behavior (updates)

https://github.com/nextui-org/nextui/assets/157580465/42a64362-4464-491c-bb35-20a4d6bab7f6

https://github.com/nextui-org/nextui/assets/157580465/8b615ff8-dfa9-484f-b33a-109f49c147be

Please describe the current behavior that you are modifying

🚀 New behavior

https://github.com/nextui-org/nextui/assets/157580465/c9b2c95e-8ac1-41d2-afe9-0950440f8a07

Please describe the behavior or changes this PR adds

💣 Is this a breaking change (Yes/No):

📝 Additional Information

Summary by CodeRabbit

  • New Features
    • Enhanced the date picker with new functionalities:
      • Added an automatic closure of the calendar header when the date picker is closed.
      • Introduced an improved control flow with an onOpenChange callback to manage the date picker's open state changes.
    • Implemented tests for Month and Year Picker functionality in the DatePicker component.

chirokas avatar Apr 22 '24 15:04 chirokas

🦋 Changeset detected

Latest commit: dff5c7cd9af8f15e9747fa71bb31cf27ea94d379

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@nextui-org/date-picker Patch
@nextui-org/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Apr 22 '24 15:04 changeset-bot[bot]

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

Name Status Preview Comments Updated (UTC)
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 8:52pm

vercel[bot] avatar Apr 22 '24 15:04 vercel[bot]

@chirokas is attempting to deploy a commit to the NextUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Apr 22 '24 15:04 vercel[bot]

[!WARNING]

Rate Limit Exceeded

@jrgarciadev has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 57 minutes and 34 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between e53dc7f22c0821e58e0b83cb1a98222a3cc6eef4 and dff5c7cd9af8f15e9747fa71bb31cf27ea94d379.

Walkthrough

The recent updates to the DatePicker component primarily focus on enhancing state management and expanding functionality. The state management for the calendar header expansion is now handled using useControlledState from @react-stately/utils. Additionally, new logic and callbacks were introduced to manage the header expansion and closing behavior. The test suite was also expanded to cover the new Month and Year Picker functionality, ensuring both controlled and uncontrolled modes work as expected.

Changes

File Summary of Changes
.../date-picker/src/use-date-picker-base.ts Refactored state management for calendar header expansion using useControlledState. Added handleHeaderExpandedChange callback and onClose function. Reorganized props handling.
.../date-picker/src/use-date-picker.ts Updated useDatePicker function to include a new onClose parameter and logic within onOpenChange callback to call onClose() when the date picker is closed.
.../date-picker/__tests__/date-picker.test.tsx Added new test cases for Month and Year Picker functionality, including tests for both controlled and uncontrolled modes, and the rendering of CalendarBottomContent.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

coderabbitai[bot] avatar Apr 22 '24 15:04 coderabbitai[bot]

If there are any problems, please guide me. Thanks!

chirokas avatar May 07 '24 06:05 chirokas

@chirokas could you please fix the tests?

jrgarciadev avatar May 24 '24 20:05 jrgarciadev