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(date-picker): resolve override of calendarProps className #3826

Closed

Conversation

alexbeno
Copy link

@alexbeno alexbeno commented Sep 30, 2024

📝 Description

This PR fixes an issue where the classNames property in the date-picker's calendarProps was being overridden, preventing custom styles from being applied.

⛳️ Current behavior (updates)

Currently, any custom styles set for the date-picker's calendar are ignored due to the classNames being overridden.

🚀 New behavior

With this change, the classNames property in calendarProps is now respected, allowing developers to apply custom styles as intended.

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

No

📝 Additional Information

Summary by CodeRabbit

  • New Features

    • Enhanced class name handling for the date-picker component, allowing custom styles to be applied effectively.
  • Bug Fixes

    • Resolved an issue where custom styles for the calendar were being overridden, ensuring proper rendering of user-defined styles.

Copy link
Contributor

coderabbitai bot commented Sep 30, 2024

Walkthrough

The changes introduce a significant update to the @nextui-org/date-picker package, specifically addressing an issue where the className property in the calendarProps was being overridden. The update ensures that custom styles are respected and rendered correctly. Additionally, the getCalendarProps function in use-date-picker.ts has been modified to merge class names from calendarProps.classNames and classNames using a new utility function, improving class name handling without altering the overall structure of the useDatePicker function.

Changes

File Change Summary
.changeset/hungry-kangaroos-kick.md Major update to @nextui-org/date-picker; fixed className overriding issue; updated getCalendarProps to merge class names using cn.

Possibly related PRs

Suggested reviewers

  • wingkwong
  • jrgarciadev

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.

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

changeset-bot bot commented Sep 30, 2024

🦋 Changeset detected

Latest commit: 952d6dc

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 Major
@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

Copy link

vercel bot commented Sep 30, 2024

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

A member of the Team first needs to authorize it.

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

🧹 Outside diff range and nitpick comments (1)
packages/components/date-picker/src/use-date-picker.ts (1)

207-211: Approved: Improved class name handling

The changes successfully address the PR objective by correctly merging the class names from calendarProps.classNames and classNames. This ensures that user-defined styles are not overridden.

However, for consistency, consider applying the same pattern to all properties in classNames:

classNames: {
  ...calendarProps.classNames,
  base: slots.calendar({class: cn(calendarProps?.classNames?.base, classNames?.calendar)}),
  content: slots.calendarContent({class: cn(calendarProps?.classNames?.content, classNames?.calendarContent)}),
  // Apply the same pattern to other properties
}

This would ensure uniform handling of all class name properties.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e308198 and 952d6dc.

📒 Files selected for processing (2)
  • .changeset/hungry-kangaroos-kick.md (1 hunks)
  • packages/components/date-picker/src/use-date-picker.ts (2 hunks)
🔇 Additional comments (4)
.changeset/hungry-kangaroos-kick.md (2)

1-3: Verify the necessity of a major version bump.

The changeset indicates a major version bump for @nextui-org/date-picker. However, the PR objectives state that this change is not breaking. Major version bumps are typically reserved for breaking changes or significant new features.

Could you please clarify why this change requires a major version bump? If it's not a breaking change, consider using a minor version bump instead.


5-5: LGTM! Clear and informative change description.

The change description accurately reflects the issue that was fixed and the expected outcome. It aligns well with the PR objectives and provides clear information for users and developers.

packages/components/date-picker/src/use-date-picker.ts (2)

13-13: LGTM: Import of cn function

The addition of the cn import from "@nextui-org/theme" is appropriate and necessary for the changes made in the getCalendarProps function. This import allows for better class name handling, which aligns with the PR objective.


Line range hint 1-254: Summary: Successful resolution of calendarProps className override

The changes in this file effectively address the PR objective of resolving the override of calendarProps className. The implementation now correctly merges user-defined and default class names, enhancing the customization capabilities of the date-picker component.

Key improvements:

  1. Addition of the cn utility function for class name merging.
  2. Updated getCalendarProps function to use cn for combining class names.

These changes ensure that custom styles applied to the date-picker's calendar are no longer ignored, improving the component's flexibility and usability.

The implementation is sound, with only a minor suggestion for consistency in class name handling. Overall, this is a valuable enhancement that aligns well with the PR's goals.

@wingkwong
Copy link
Member

handled in #3773 already.

@wingkwong wingkwong closed this Sep 30, 2024
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.

2 participants