shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
70.67k stars 4.25k forks source link

Date picker with popover is not opening #910

Open ashreyas431 opened 1 year ago

ashreyas431 commented 1 year ago

Date picker is put into a separate component and called wherever needed but on clicking the date picker calendar is not showing

luanlucho commented 1 year ago

Same. Works in Chrome but not in Firefox

erkanaltinors commented 1 year ago

I got this error on my Astro project. I've fixed it by adding client directive to react component where it is imported into astro page.

kitsunekyo commented 11 months ago

you can try to hotfix it in your apps by removing the initialFocus attribute on <Calendar. let me know if this works for you.

PeterGKafkakis commented 9 months ago

Taking out initialFocus on datepicker.tsx did work for me.

imksmv commented 9 months ago

Taking out initialFocus on datepicker.tsx did work for me.

Indeed. So now on mobile devices it opens as well.

diogocezar commented 8 months ago

Worked for me too :D thanks <3

mahamrana703 commented 7 months ago

Worked for me too

lmac-1 commented 7 months ago

Thanks! Date picker wasn't opening for me on Firefox within a modal but removing initialFocus fixed the problem for me.

sijirama commented 7 months ago

ahh, thanks, that definitely did it, after removing initialFocus fixed it.

M1ck0 commented 6 months ago

removing initialFocus did not work for me. Any ideas?

After bit of debugging I've noticed that <div data-radix-popper-content-wrapper>...</div> has these CSS styles inlined

    position: fixed;
    left: 0px;
    top: 0px;
    transform: translate(0px, -200%);
    min-width: max-content;
    will-change: transform;
    z-index: 50;

This pushes is out of view

jassibacha commented 6 months ago

So this can actually be fixed by adding modal={true} to the <Popover>, and doesn't lose the initialFocus that way. Suggested here by @morgan4080

EvansRobbie commented 5 months ago

datepicker

I had a similar issue. I used fowardRef in my trigger i.e. button to fix this.

earhengleap commented 3 months ago

So this can actually be fixed by adding modal={true} to the <Popover>, and doesn't lose the initialFocus that way. Suggested here by @morgan4080

It really worked.

wasiowision commented 3 months ago

So this can actually be fixed by adding modal={true} to the <Popover>, and doesn't lose the initialFocus that way. Suggested here by @morgan4080

Thankyou So Much man it works for me 🏆

mustakimkr commented 2 months ago

So this can actually be fixed by adding modal={true} to the <Popover>, and doesn't lose the initialFocus that way. Suggested here by @morgan4080

I was rendering a date picker inside a Sheet. It started behaving weirdly. Then this solution worked for me.

Rufai-Ahmed commented 2 months ago

I an issue where the datepicker's CSS is not looking well. ![Uploading image.png…]()

Rufai-Ahmed commented 2 months ago

Screenshot (147)

Rufai-Ahmed commented 2 months ago

The code:

`"use client";

import * as React from "react"; import { format } from "date-fns"; import { Calendar as CalendarIcon } from "lucide-react";

import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import { Calendar } from "@/components/ui/calendar"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover";

export function DatePickerDemo() { const [date, setDate] = React.useState();

return (

); } `
efgomes commented 2 months ago

image

Could anyone help me with how to resolve this situation?

aidrecabrera commented 2 months ago

I have also encountered with this issue too. It seems that the date range picker component's styling is broken because of the latest version of react-day-picker, in my case version 9.0.0.

Here is a workaround for this:

  1. Delete the problematic version:

    pnpm remove react-day-picker
  2. Install the older version of react-day-picker

    pnpm add react-day-picker@^8.9.1

Hopefully that should fix the issue. Version 8.9.1 is working fine on my end.

image image

Hope this helps! @efgomes @Rufai-Ahmed

aidrecabrera commented 2 months ago

Easiest solution right now is to downgrade to 8.10.1. The react-day-picker team has already been notified of this issue in the v9.0.0 release announcement

Describe the bug

CleanShot 2024-07-21 at 17 46 51@2x

Currently, the component looks like this.

Fix: You can currently fix this by downgrading react-day-picker to version 8.^

Affected component/components

Calendar, Date Picker, ...

How to reproduce

  1. Install Calendar component

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Browsers

Before submitting

  • [x] I've made research efforts and searched the documentation
  • [x] I've searched for existing issues
liamicy3aaa commented 2 months ago

Thanks @aidrecabrera. Now works after downgrading to 8.10.1

MuhammedNihad commented 2 months ago

I too ran into same issue. Datepicker styles were broken. Downgraded to 8.10.1 and it works well. Hope this will be fixed on 9.0.0 soon. Thanks very much @aidrecabrera

thanhlq commented 2 months ago

I got the same issue with 9.0.1, 8.10.1 working fine!

moha-abdi commented 1 month ago

So this can actually be fixed by adding modal={true} to the <Popover>, and doesn't lose the initialFocus that way. Suggested here by @morgan4080

Thanks lad! it works

techcoder2007 commented 1 month ago

position: fixed; left: 0px; top: 0px; transform: translate(0px, -200%); min-width: max-content; will-change: transform; z-index: 50;

this steps did work for me.