-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 needs double click when minDate/ MaxDate property is set. #4641
Comments
Please see plunker (http://plnkr.co/edit/1D1LY2Gtb6nXrFUOZm6G?p=preview), please remove minDate function and add ngOnInit because component always check maxDate value |
I'm still having this problem. Sometimes you just want a function in the min and max date options. When you do, you have to click twice to select a date. |
Can we reopen this? |
@Merve7 Why did you close this issue? The issue is still reproducible. |
I've updated my stackblitz example to v6.1.4. The problem is still there. |
@kareljan You are totally right that it still doesn't work as expected, but as @Merve7 said - you should NOT provide functions calls for minDate/maxDate property values. |
I use the latest Primeng 8.0.1 and this issue still happend, please reopen and fix it. Thank you so much ^^ |
Hi everyone, We'll check and get back to you. Best Regards, |
@tranthoai Hello there, I managed to fix this in a project I worked on, but I need some time to remind myself how I did it. |
This is expected, when a getter is bound, clicking the date cell reruns the change detection and Angular replaces it with the new dom because minDate and maxDate changes causes dom updates, so after first click the cell is gone so click is not executed, at second click the cell is there so it is triggered. Solution is using property values as https://stackblitz.com/edit/angular-4oyncc |
@cagataycivici I am still facing the same issue. can you please make it simple like have single calender and its min and max date for e.g: is between 1954 to 2009 |
Does it work with reactive forms? I can't get it. It is quite annoying behavior. When I change month and then click on a day, it works. When I only click on a day, I have to do it twice. Solution: As above. Move it to property. Getter or function doesn't work. |
Alternative approach and additional explanation for anybody still struggling with it. The issue happens because the min/max binding changes value. In my case I have many date pickers (p-calendar) on a page. Each next date picker should allow only dates after the date selected in previous control. I don't want to define getter and additional field for every control. So, the solution I found is to use memoization from lodash-decorators-esm package. This way my function does not return new object if there was no real change of the value.
Then use it like this: |
There is no guarantee in receiving a response in GitHub Issue Tracker, If you'd like to secure our response, you may consider PrimeNG PRO Support where support is provided within 4 business hours
I'm submitting a ... (check one with "x")
Plunkr Case (Bug Reports)
Please fork the plunkr below and create a case demonstrating your bug report. Issues without a plunkr have much less possibility to be reviewed.
http://plnkr.co/edit/ZXkmtf1OFKmQokyEdmwa?p=preview
Current behavior
When minDate or maxDate property is set, calendar needs two clicks to select date.
Expected behavior
It should select date in single click.
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
Language: [all]
Node (for AoT issues):
node --version
=The text was updated successfully, but these errors were encountered: