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: updateViewDate method brings the error with null value #6422

Closed
galimovkirill opened this issue Apr 19, 2024 · 0 comments · Fixed by #6425, leoo1992/GeradorQRCode#23 or leoo1992/GeradorQRCode#27
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@galimovkirill
Copy link

galimovkirill commented Apr 19, 2024

Describe the bug

I have this example code, where I need to reset calendar's date manually via its API (https://primereact.org/calendar/#api.Calendar.methods).

image

In this example I'm trying to call method updateViewDate, passing null inside it.

But in fact, I'm getting the error while pressing the button:

image

If I try to check the source code from the link in call stack, I will see that the method updateViewDate calls setCurrentMonth(value.getMonth()) without checking for truthy of value (the same thing for year property).

image

Note: the API of this method is documented, that it can accept Nullable (value: Nullable<Date | Date[]>)

My suggestion is to check value for truthy before trying to set month/year in this method.

Reproducer

https://codesandbox.io/p/devbox/objective-lena-ypxjyy?file=%2Fsrc%2FApp.tsx%3A22%2C16

PrimeReact version

10.6.3

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

  1. Try to call method updateViewDate and pass null to reset date.

Expected behavior

No response

@galimovkirill galimovkirill added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 19, 2024
@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 Apr 19, 2024
@melloware melloware added this to the 10.6.4 milestone Apr 19, 2024
melloware added a commit that referenced this issue Apr 19, 2024
* Fix#6422

* Update components/lib/calendar/Calendar.js

Co-authored-by: Melloware <[email protected]>

---------

Co-authored-by: Melloware <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
2 participants