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: crash when using props "viewDate" and "onSelect" #6746

Closed
adrianhurt opened this issue Jun 11, 2024 · 1 comment · Fixed by #6748, leoo1992/GeradorQRCode#57 or leoo1992/GeradorQRCode#80 · May be fixed by nhattpn/BTL_LTNC#56
Closed
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@adrianhurt
Copy link

Describe the bug

When using props onSelect and viewDate together, a render crash appear with

TypeError: Cannot read properties of null (reading 'currentTarget')
    at onDateSelect2 (primereact_calendar.js?v=f83b75ed:6573:11)
    at updateViewDate2 (primereact_calendar.js?v=f83b75ed:6121:7)

This example works fine:

<Calendar
    value={date}
    onChange={(e) => setDate(e.value)}
    onSelect={() => {}}
/>

And this one:

<Calendar
    value={date}
    onChange={(e) => setDate(e.value)}
    viewDate={new Date('2024-01-01')}
/>

But using both does not work:

<Calendar
    value={date}
    onChange={(e) => setDate(e.value)}
    onSelect={() => {}}
    viewDate={new Date('2024-01-01')}
/>

Reproducer

https://stackblitz.com/edit/q4um9w?file=src%2FApp.jsx

PrimeReact version

latest

React version

18.x

Language

ES6

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

It should work properly letting us to handle the onSelect callback and using the viewDate prop

@adrianhurt adrianhurt 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 11, 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 Jun 12, 2024
@melloware melloware added this to the 10.7.0 milestone Jun 12, 2024
@adrianhurt
Copy link
Author

Thanks @melloware!!

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