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-range-picker): fixed input overflow #3076

Open
wants to merge 5 commits into
base: canary
Choose a base branch
from

Conversation

ShrinidhiUpadhyaya
Copy link
Contributor

@ShrinidhiUpadhyaya ShrinidhiUpadhyaya commented May 25, 2024

Closes #3037

📝 Description

When the component was on mobile screen, its contents were overflowing.

⛳️ Current behavior (updates)

image

image

🚀 New behavior

image

image

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

📝 Additional Information

If the PR gets accepted please use my GitHub email-id (shrinidhiupadhyaya1195@gmail.com) instead of my other email-id for the Co-authored-by: message.

Summary by CodeRabbit

  • New Features

    • Added an optional classNames property for enhanced customization of date range picker components.
  • Style

    • Improved layout stability in the date range picker by adding flexShrink: 0.
    • Enhanced date input component by applying overflow-hidden to prevent content overflow.
  • Bug Fixes

    • Fixed input overflow issue in the date range picker component.

Copy link

changeset-bot bot commented May 25, 2024

🦋 Changeset detected

Latest commit: d191b82

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

Copy link

vercel bot commented May 25, 2024

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

Name Status Preview Comments Updated (UTC)
nextui-docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 4, 2024 6:07am
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 4, 2024 6:07am

Copy link

vercel bot commented May 25, 2024

Someone 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 bot commented May 25, 2024

Walkthrough

This update primarily addresses layout issues with the date-range-picker and date-input components in the @nextui-org/date-picker package. The key changes include the addition of a classNames property to the useDateRangePicker function for enhanced styling customization and the addition of overflow-hidden to the dateInput component's base and input styles to manage overflowing content effectively, especially on small screens.

Changes

File Path Change Summary
packages/components/date-picker/src/use-date-range-picker.ts Added an optional classNames property for styling customization and updated getStartDateInputProps to include flexShrink: 0.
packages/core/theme/src/components/date-input.ts Added overflow-hidden to the base and input styles to handle text overflow within the component.

Assessment against linked issues

Objective Addressed Explanation
Prevent overflow in the date-range-picker on mobile (##3037)
Ensure text truncation within the date-range-picker on small screens (##3037)
Apply overflow-hidden to manage text overflow in dateInput component (##3037)

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
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 (3)
packages/components/date-picker/src/use-date-range-picker.ts (3)

Line range hint 98-98: Consider using const instead of let for variables that are assigned only once.

- let state: DateRangePickerState = useDateRangePickerState({
+ const state: DateRangePickerState = useDateRangePickerState({

Also applies to: 106-106


Line range hint 123-123: Simplify the dependency arrays for the useMemo hooks.

- [objectToDeps(variantProps), className],
+ [variantProps, className],

Also applies to: 267-267


Line range hint 214-214: Simplify the computed expression without using a string literal.

- label: stringFormatter.format("startTime"),
+ label: stringFormatter.format(startTime),
Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between fa26ce0 and 8dbb37a.
Files selected for processing (2)
  • packages/components/date-picker/src/use-date-range-picker.ts (1 hunks)
  • packages/core/theme/src/components/date-input.ts (2 hunks)
Additional Context Used
Biome (8)
packages/components/date-picker/src/use-date-range-picker.ts (8)

214-214: The computed expression can be simplified without the use of a string literal.


98-98: This let declares a variable that is only assigned once.


106-106: This let declares some variables that are only assigned once.


123-123: This hook does not specify all of its dependencies: variantProps


123-123: This hook specifies more dependencies than necessary: objectToDeps(variantProps)


267-267: This hook does not specify all of its dependencies: labelPlacement


267-267: This hook does not specify all of its dependencies: variantProps


267-267: This hook specifies more dependencies than necessary: objectToDeps(variantProps)

Additional comments not posted (3)
packages/core/theme/src/components/date-input.ts (2)

12-12: LGTM! The addition of overflow-hidden to the base slot should help prevent overflow issues.


24-24: LGTM! The addition of overflow-hidden to the input slot should help manage content overflow effectively.

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

293-293: LGTM! Setting flexShrink: 0 ensures that the date input fields do not shrink, helping to maintain layout consistency on smaller screens.

@wingkwong wingkwong self-assigned this May 27, 2024
Copy link
Member

@wingkwong wingkwong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, we can't scroll to see the value.

image

@@ -290,6 +290,7 @@ export function useDateRangePicker<T extends DateValue>({
style: {
...props.style,
maxWidth: "fit-content",
flexShrink: 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have to set it here instead of packages/core/theme/src/components/date-input.ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have set it here as there was no slot just for start-input.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the scrolling, could we wrap the start-input and end-input inside a div? So that we could achieve something like this

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have set it here as there was no slot just for start-input.

just a few lines below

className: dateInputSlots.input({
  class: clsx(classNames?.input, props?.className),
}),

Regarding the scrolling, could we wrap the start-input and end-input inside a div? So that we could achieve something like this

I think it's fine. We should only scroll the input. The scrollbar can look better tho.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few lines below

className: dateInputSlots.input({
  class: clsx(classNames?.input, props?.className),
}),

I guess we might not need flexShrink: 0 as we are adding a scrollbar.

I think it's fine. We should only scroll the input.

If we dont add a div wrapper then the complete input-wrapper will be scrolled and by default the calendar button is not visible, we need to scroll to press the calendar button.

image

image

The scrollbar can look better tho.

I have used the default scrollbar like the components Table or ScrollShadow.

Is their a custom scrollbar already present or do you want to me implement one?

Apart from the default scrollbar, the only scrollbar i found being used in the project is the below one? Do you want to me make use of this?
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the default scrollbar first. we may refactor later.

Copy link
Contributor Author

@ShrinidhiUpadhyaya ShrinidhiUpadhyaya Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we might need to increase the height of the component or customize the height of the scrollbar as just applying scrollbar hides the input as shown below:-
image

Do you want me to increase the height? If yes could you tell me the values to which i need to increase?
Currently the innerWrapper height is set h-6 and the size of the inputWrapper is h-8 h-10 h-12 for size sm md & lg respectively.

Or should we create a custom scrollbar so that it could be used in other places and consistency is maintained?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think not. the height shouldn't be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the height is not changed then the text will not be visible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the scrollbar shouldn't look like this. may double check with other pages. I rmb it was quite thin.

@wingkwong wingkwong changed the title fix(date-range-picker): fixed input overflow #3037 fix(date-range-picker): fixed input overflow Jun 25, 2024
Copy link
Member

@wingkwong wingkwong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you've modified code in packages, please include a changeset.

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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8dbb37a and 868d60a.

Files selected for processing (1)
  • packages/components/date-picker/src/use-date-range-picker.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/components/date-picker/src/use-date-range-picker.ts

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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 868d60a and cbd4c38.

Files selected for processing (1)
  • .changeset/ten-ways-confess.md (1 hunks)
Additional comments not posted (1)
.changeset/ten-ways-confess.md (1)

1-5: Changeset Documentation Looks Good!

The changeset correctly identifies the package (@nextui-org/date-picker) and the nature of the change (patch). The description is clear and directly addresses the issue fixed by this patch.

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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cbd4c38 and d191b82.

📒 Files selected for processing (1)
  • packages/components/date-picker/src/use-date-range-picker.ts (1 hunks)

@@ -294,6 +294,7 @@ export function useDateRangePicker<T extends DateValue>({
style: {
...props.style,
maxWidth: "fit-content",
flexShrink: 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider a more comprehensive solution for the overflow issue

While adding flexShrink: 0 may prevent the start date input from shrinking, it might not fully address the overflow problem described in the PR objectives. This solution could potentially create layout issues in certain scenarios, especially on smaller screens.

Instead, consider implementing a more robust solution that addresses the root cause of the overflow:

  1. Wrap both start and end inputs in a scrollable container, as suggested in the past review comments.
  2. Implement text truncation for long date strings, as mentioned in the expected behavior from the linked issue.
  3. Ensure the calendar button remains visible and accessible at all times.

Here's a potential implementation:

-style: {
-  ...props.style,
-  maxWidth: "fit-content",
-  flexShrink: 0,
-},
+style: {
+  ...props.style,
+  maxWidth: "100%",
+  overflow: "hidden",
+  textOverflow: "ellipsis",
+  whiteSpace: "nowrap",
+},
+wrapperStyle: {
+  display: "flex",
+  overflow: "auto",
+  maxWidth: "100%",
+},

Then, in the component that uses these props, wrap the inputs in a div with the wrapperStyle.

This approach would allow the date text to truncate when necessary, while still providing a scrollable interface for users to see the full date if needed.

Would you like assistance in implementing this solution across the component?

Committable suggestion was skipped due to low confidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - DATE_RANGE_PICKER_OVERFLOW
2 participants