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

Calendar: The date cannot be selected from the first click in the opened popup #4568

Open
safronov-dmitrii opened this issue Jun 28, 2023 · 14 comments · Fixed by #4584
Open
Assignees
Labels
Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@safronov-dmitrii
Copy link

safronov-dmitrii commented Jun 28, 2023

Describe the bug

The date cannot be selected from the first click in the opened popup.
You have to double-click on the date in the opened calendar to display the selected date in the input.

It is important that the popup is opened by clicking on the input field. If the popup is opened via icon, then the problem is not reproduced.

The bug cannot be reproduced in version 9.5.0.

Reproducer

https://stackblitz.com/edit/react-w6bsse

PrimeReact version

9.6.0

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

  1. Click on the input field (not on the icon button) to open the calendar;
  2. Click on any date.

Expected behavior

The date can be selected in the calendar with a single mouse click.

@safronov-dmitrii safronov-dmitrii added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jun 28, 2023
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jun 28, 2023
@melloware
Copy link
Member

I updated your ticket with a reproducer.

@djapal
Copy link

djapal commented Aug 1, 2023

Why was this fix not included in 9.6.1? How much time will version 10 take to be released?

@melloware
Copy link
Member

From PrimeTek: " 9.6.1 just includes our PRO support fixes that's why we didn't apply other PRs"

@melloware
Copy link
Member

Fixed in 9.6.2 if you want to give it a try

@maitrungduc1410
Copy link

Hi @melloware

I'm using 9.6.2 and this issue is still there, I need to click twice to select date.

Reproducer: https://codesandbox.io/p/sandbox/hardcore-hooks-rvkpxr

@melloware
Copy link
Member

@maitrungduc1410 it looks like Vite is processing faster or differently than Create React App but I am pretty sure this is fixed for 10.0.0

@joseanfernandez
Copy link

@maitrungduc1410 I also have the same problem with version 9.6.2, for now I have solved it like this:

      <Calendar
        onFocus={handleCalendarFocus}
        ...
        />
const handleCalendarFocus = () => {
   setTimeout(() => {
     const datePickerCollection =
       document.getElementsByClassName('p-datepicker');
     if (datePickerCollection.length) {
       const datePicker = datePickerCollection.item(0) as HTMLDivElement;
       datePicker.setAttribute('tabindex', '0');
       datePicker.focus();
     }
   }, 500);
 };

@maitrungduc1410
Copy link

@melloware, Somehow I'm still facing same issue in my NextJS project (next 13.4.12 and PrimeReact 9.6.2), it's hard to tell what's going on

The example is this, this Sandbox works: https://codesandbox.io/p/sandbox/beautiful-sky-6gf553

In my production code, I copy exactly same as above example, but it doesn't work:

ezgif-4-0133cf8636

as you can see, everytime I select a date, the overlay is closed, and I have to click again.

Weird, exactly same code as the Sandbox (both are NextJS, same version of all packages: next, primereact...)

I think I should wait for primereact v10 and try again

@melloware
Copy link
Member

Yes I am pretty sure this is fixed in V10 because I am testing using NextJS and the showcase right now and the Calendar seems to be working fine in 10.0.0. Let me know when 10.0.0 comes out if it is still not working.

@pedrofg
Copy link

pedrofg commented May 2, 2024

Version 10.6.3 still has this same problem :/ so silly, the workaround mentioned by @joseanfernandez works

@melloware melloware added the Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team label May 2, 2024
bwamsellem pushed a commit to bwamsellem/primereact that referenced this issue Jun 2, 2024
@sevastosm
Copy link

Version 10.6.3 still has this same problem , the workaround mentioned by @joseanfernandez not working if you use mask or type the date on input, it triggers focus on panel and is not possible to write.

@melloware melloware reopened this Jul 7, 2024
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jul 7, 2024
@MarcoCPinho
Copy link

Version 10.7 with Vite still happens. I have the problem that @sevastosm said, can't use workaround because I need a mask and input type available =/.
Downgraded back to 9.6.3 and works just fine.
PS: I'm using calendar inside an Datatable, with "cell" edit mode, rendering the Calender inside the "editor" prop.

@melloware melloware removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jul 16, 2024
@F4ssi
Copy link

F4ssi commented Aug 1, 2024

Using this in Version 10.8.0 with Vite and still have the same issue. Similar Problem as @MarcoCPinho can't use the workaround because we need to use a mask and the input field.
Can use the workaround with the onShow instead of the onFocus though, but still not very nice behaviour of the component then.

@lekhnath
Copy link

Now the calendar popup does not close on first time click outside.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
10 participants