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

[bug]: datepicker get a wrong css #4361

Closed
2 tasks done
jizhi0v0 opened this issue Jul 21, 2024 · 11 comments
Closed
2 tasks done

[bug]: datepicker get a wrong css #4361

jizhi0v0 opened this issue Jul 21, 2024 · 11 comments
Labels
bug Something isn't working

Comments

@jizhi0v0
Copy link

Describe the bug

Not displayed as expected

Affected component/components

Date Picker

How to reproduce

1.Click on datepicker component

Google Chrome 2024-07-21 20 41 32

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Browsers

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@jizhi0v0 jizhi0v0 added the bug Something isn't working label Jul 21, 2024
@plutack
Copy link

plutack commented Jul 21, 2024

I have been battling this for the past 12hrs no cap. Since I am not very familiar with shadcn and react components, I was under the assumption I am doing something wrong.
I am also getting some errors after installing calendar.
Caption does not seem to exist in type partial < classnames > . I can't also seem to find it any where after navigating through the UI types where something like caption _label can be found.
Same thing for iconLeft which is suppose to exist in partial < customComponents >

@activemonkeys
Copy link

Did you install the new react-day-picker v9.0.0? That one seems to come with several breaking changes. When using react-day-picker 8.10.1 you will probably be fine for the moment.

@plutack
Copy link

plutack commented Jul 21, 2024

@activemonkeys I will try that now. I have v9 installed

Edit : works for me too.. big thanks

@jizhi0v0
Copy link
Author

Did you install the new react-day-picker v9.0.0? That one seems to come with several breaking changes. When using react-day-picker 8.10.1 you will probably be fine for the moment.

It works,Thank you so much!

@jizhi0v0
Copy link
Author

I have been battling this for the past 12hrs no cap. Since I am not very familiar with shadcn and react components, I was under the assumption I am doing something wrong. I am also getting some errors after installing calendar. Caption does not seem to exist in type partial < classnames > . I can't also seem to find it any where after navigating through the UI types where something like caption _label can be found. Same thing for iconLeft which is suppose to exist in partial < customComponents >

You should run the below command

@firdoesdev
Copy link

Did you install the new react-day-picker v9.0.0? That one seems to come with several breaking changes. When using react-day-picker 8.10.1 you will probably be fine for the moment.

Thank You! it's work 👍

@masewo
Copy link

masewo commented Jul 21, 2024

Tried to migrate the shadcn Calendar to react-date-picker 9.x.x but I gave up since I cannot find out how to attach the hover styles to the day button and not to the day cell...

Click me
import * as React from "react";
import { ChevronLeft, ChevronRight } from "lucide-react";
import { DayPicker } from "react-day-picker";

import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/ui/button";

export type CalendarProps = React.ComponentProps<typeof DayPicker>;

function Calendar({
className,
classNames,
showOutsideDays = true,
...props
}: CalendarProps) {
return (
  <DayPicker
    showOutsideDays={showOutsideDays}
    className={cn("p-3", className)}
    classNames={{
      months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
      month: "space-y-4",
      month_caption: "flex justify-center pt-1 relative items-center",
      caption_label: "text-sm font-medium",
      nav: "space-x-1 flex items-center",
      button_previous: cn(
        buttonVariants({ variant: "outline" }),
        "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
        "absolute left-10 top-[70px] z-10",
      ),
      button_next: cn(
        buttonVariants({ variant: "outline" }),
        "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
        "absolute right-6 top-[70px] z-10",
      ),
      month_grid: "w-full border-collapse space-y-1",
      weekdays: "flex",
      weekday:
        "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
      week: "flex w-full mt-2",
      day: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
      day_button: cn(
        buttonVariants({ variant: "ghost" }),
        "h-9 w-9 p-0 font-normal aria-selected:opacity-100",
      ),
      selected:
        "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
      today: "bg-accent text-accent-foreground",
      outside: "text-muted-foreground opacity-50",
      disabled: "text-muted-foreground opacity-50",
      range_middle:
        "aria-selected:bg-accent aria-selected:text-accent-foreground",
      hidden: "invisible",
      ...classNames,
    }}
    components={{
      Chevron: (props) =>
        props.orientation === "left" ? (
          <ChevronLeft className="h-4 w-4" />
        ) : (
          <ChevronRight className="h-4 w-4" />
        ),
    }}
    {...props}
  />
);
}
Calendar.displayName = "Calendar";

export { Calendar };

Another thing I noticed is that the range is not updating after choosing an entry from the preset list.

@efgomes
Copy link

efgomes commented Jul 21, 2024

image
I'm using 9.0, and my calendar is like this

@Geeraldv
Copy link

Geeraldv commented Jul 24, 2024

Did you install the new react-day-picker v9.0.0? That one seems to come with several breaking changes. When using react-day-picker 8.10.1 you will probably be fine for the moment.

Thank You! it's work for me 👍

@kachkaev
Copy link
Contributor

kachkaev commented Aug 30, 2024

PRs with fixes: #4371 & #4421

@tresorama
Copy link

tresorama commented Nov 13, 2024

In meantime, if someone want to use both v8 and v9 at the same time, it's possible to have both.
shadcn can use v8 and you can use v9 when you want.

https://medium.com/weekly-webtips/how-to-install-multiple-versions-of-the-same-package-in-npm-71c29b12e253

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants