ui icon indicating copy to clipboard operation
ui copied to clipboard

Date picker with popover is not opening

Open ashreyas431 opened this issue 1 year ago • 25 comments

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

ashreyas431 avatar Jul 12 '23 11:07 ashreyas431

Same. Works in Chrome but not in Firefox

luanlucho avatar Sep 22 '23 20:09 luanlucho

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.

erkanaltinors avatar Sep 30 '23 13:09 erkanaltinors

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

kitsunekyo avatar Oct 19 '23 07:10 kitsunekyo

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

PeterGKafkakis avatar Dec 13 '23 02:12 PeterGKafkakis

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

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

imksmv avatar Dec 22 '23 14:12 imksmv

Worked for me too :D thanks <3

diogocezar avatar Feb 04 '24 22:02 diogocezar

Worked for me too

mahamrana703 avatar Feb 21 '24 06:02 mahamrana703

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

lmac-1 avatar Feb 23 '24 20:02 lmac-1

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

sijirama avatar Feb 26 '24 21:02 sijirama

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

M1ck0 avatar Mar 08 '24 13:03 M1ck0

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

jassibacha avatar Mar 19 '24 19:03 jassibacha

datepicker

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

EvansRobbie avatar Apr 26 '24 02:04 EvansRobbie

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.

earhengleap avatar Jun 20 '24 17:06 earhengleap

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 🏆

wasiowision avatar Jun 26 '24 18:06 wasiowision

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.

mustakimkr avatar Jul 12 '24 18:07 mustakimkr

I an issue where the datepicker's CSS is not looking well. Uploading image.png…

Rufai-Ahmed avatar Jul 21 '24 12:07 Rufai-Ahmed

Screenshot (147)

Rufai-Ahmed avatar Jul 21 '24 12:07 Rufai-Ahmed

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<Date>();

return ( <Popover modal={true}> <PopoverTrigger asChild> <Button variant={"outline"} className={cn( "w-[280px] justify-start text-left font-normal", !date && "text-muted-foreground" )} > <CalendarIcon className="mr-2 h-4 w-4" /> {date ? format(date, "PPP") : Pick a date} </Button> </PopoverTrigger> <PopoverContent className="w-auto p-0"> <Calendar mode="single" selected={date} onSelect={setDate} /> </PopoverContent> </Popover> ); } `

Rufai-Ahmed avatar Jul 21 '24 12:07 Rufai-Ahmed

image

Could anyone help me with how to resolve this situation?

efgomes avatar Jul 21 '24 14:07 efgomes

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
  1. 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 avatar Jul 21 '24 21:07 aidrecabrera

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

aidrecabrera avatar Jul 21 '24 21:07 aidrecabrera

Thanks @aidrecabrera. Now works after downgrading to 8.10.1

liamicy3aaa avatar Jul 21 '24 22:07 liamicy3aaa

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

MuhammedNihad avatar Jul 22 '24 01:07 MuhammedNihad

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

thanhlq avatar Jul 22 '24 07:07 thanhlq

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

moha-abdi avatar Aug 08 '24 14:08 moha-abdi