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(datepicker) duplicate month display #1456 #1457

Merged
merged 2 commits into from
Aug 5, 2024

Conversation

khareembld
Copy link
Contributor

@khareembld khareembld commented Jul 29, 2024

Add isMonthEqual utility
Update Months.tsx to not clone viewDate and set date to 1 to avoid date overflow

image

Summary by CodeRabbit

  • New Features
    • Introduced a new utility function for comparing months in the Datepicker component.
  • Enhancements
    • Updated the Datepicker component to focus on month-level operations, simplifying date management.
    • Removed the viewDate prop to streamline the component's state management.

Copy link

changeset-bot bot commented Jul 29, 2024

⚠️ No Changeset found

Latest commit: 15de372

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented Jul 29, 2024

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

Name Status Preview Comments Updated (UTC)
flowbite-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 5, 2024 6:02am
flowbite-react-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 5, 2024 6:02am

Copy link
Contributor

coderabbitai bot commented Jul 29, 2024

Walkthrough

The changes enhance the Datepicker component's month selection logic by introducing a new utility function, isMonthEqual, for comparing months. The Months.tsx file has been updated to eliminate the viewDate prop, streamlining the component's state management. This refinement allows for more straightforward month-level operations, ultimately improving the overall functionality of the date picker.

Changes

Files Change Summary
.../Datepicker/Views/Months.tsx Updated month selection logic; removed viewDate prop; replaced isDateEqual with isMonthEqual.
.../Datepicker/helpers.ts Introduced isMonthEqual function for comparing month values of Date objects.

Poem

In the garden where the daisies play,
A rabbit hops through bright new day.
With months aligned and dates in sync,
Our picker twirls, a joyful wink!
Burrows deep, where changes bloom,
A simpler path dispels the gloom. 🐇✨


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.
    • @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 as 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.

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

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
Contributor

@coderabbitai coderabbitai bot left a 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 83e5583 and 091b520.

Files selected for processing (2)
  • packages/ui/src/components/Datepicker/Views/Months.tsx (3 hunks)
  • packages/ui/src/components/Datepicker/helpers.ts (1 hunks)
Additional comments not posted (5)
packages/ui/src/components/Datepicker/Views/Months.tsx (4)

5-5: LGTM! Import change aligns with new logic.

The import statement now includes isMonthEqual instead of isDateEqual, which aligns with the new month-level comparison logic.


38-40: LGTM! Initialization change avoids overflow issues.

The newDate object is now initialized with the current date, the month set to the current index, and the day explicitly set to 1 to avoid overflow issues.


43-43: LGTM! Month selection logic updated.

The check for whether a month is selected now uses isMonthEqual instead of isDateEqual, aligning with the new month-level comparison logic.


Line range hint 44-55:
LGTM! View date and view update logic.

The onClick handler sets the viewDate and view if the month is not disabled, ensuring the correct update of the view date and view when a month is selected.

packages/ui/src/components/Datepicker/helpers.ts (1)

47-49: LGTM! New utility function for month comparison.

The isMonthEqual function compares the month values of two Date objects, providing a straightforward way to compare month values.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 091b520 and 3fd935a.

Files selected for processing (1)
  • packages/ui/src/components/Datepicker/Views/Months.tsx (2 hunks)
Additional comments not posted (4)
packages/ui/src/components/Datepicker/Views/Months.tsx (4)

5-5: Import changes approved.

The import of isMonthEqual aligns with the updated logic for month comparison, replacing isDateEqual.


23-23: Removal of viewDate from context values.

The removal of viewDate from the destructured context values simplifies the component's state management.


30-32: Initialize newDate to avoid overflow issues.

The initialization of newDate with the day set to 1 prevents overflow issues when setting the month.


35-35: Use isMonthEqual for month comparison.

The use of isMonthEqual for checking if a month is selected aligns with the new month-level comparison logic.

@rluders
Copy link
Collaborator

rluders commented Aug 5, 2024

Thanks

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3fd935a and 15de372.

Files selected for processing (2)
  • packages/ui/src/components/Datepicker/Views/Months.tsx (2 hunks)
  • packages/ui/src/components/Datepicker/helpers.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/ui/src/components/Datepicker/helpers.ts
Additional comments not posted (4)
packages/ui/src/components/Datepicker/Views/Months.tsx (4)

5-5: Import statement updated correctly.

The import of isMonthEqual aligns with the new month comparison logic.


30-32: Setting day to 1 to avoid overflow issues is a good practice.

The initialization of newDate with the day set to 1 helps prevent overflow issues when manipulating date values.


35-35: Correct usage of isMonthEqual for month comparison.

The use of isMonthEqual for checking if a month is selected aligns with the new focus on month comparison.


23-23: Ensure the removal of viewDate does not affect functionality.

The viewDate prop has been removed from the destructured context values. Verify that this change does not introduce any issues in other parts of the component or codebase.

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.

3 participants