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

Checkbox: prop onClick changes the event type in 10.5.3 #6231

Closed
datacampsis opened this issue Mar 26, 2024 · 8 comments · Fixed by #6232, #6485 or leoo1992/GeradorQRCode#23
Closed

Checkbox: prop onClick changes the event type in 10.5.3 #6231

datacampsis opened this issue Mar 26, 2024 · 8 comments · Fixed by #6232, #6485 or leoo1992/GeradorQRCode#23
Assignees
Labels
Typescript Issue or pull request is *only* related to TypeScript definition

Comments

@datacampsis
Copy link
Contributor

Describe the bug

In version 10.5.0, the Checkbox's onClick event type was CheckboxClickEvent:
image

Now is HtmlDivElement, and property checked not exists:
image

Reproducer

https://stackblitz.com/edit/ovmva7?file=src%2FApp.tsx

PrimeReact version

10.5.3

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

Expects the type CheckboxClickEvent and access the checked prop

@datacampsis datacampsis added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Mar 26, 2024
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. Typescript Issue or pull request is *only* related to TypeScript definition and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible Type: Bug Issue contains a defect related to a specific component. labels Mar 26, 2024
melloware added a commit to melloware/primereact that referenced this issue Mar 26, 2024
@melloware melloware self-assigned this Mar 26, 2024
@melloware melloware added this to the 10.6.0 milestone Mar 26, 2024
melloware added a commit to melloware/primereact that referenced this issue Mar 27, 2024
nitrogenous added a commit that referenced this issue Mar 29, 2024
Fix #6231: Checkbox typescript and onClick event
@melloware melloware removed this from the 10.6.0 milestone Apr 17, 2024
@melloware melloware reopened this Apr 17, 2024
@melloware
Copy link
Member

Looks like this is a still an issue in 10.6.3

@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 Apr 17, 2024
@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 Apr 17, 2024
@melloware
Copy link
Member

@dvpritzbuer interested in helping with this one? The Checkbox Typescript def is definitely not correct.

@dvpritzbuer
Copy link
Contributor

@melloware if it's not super urgent and next week would be fine for the PR I can have a look at it

@melloware
Copy link
Member

@dvpritzbuer much appreciated next week is fine!

@melloware melloware assigned dvpritzbuer and unassigned melloware Apr 18, 2024
@dvpritzbuer
Copy link
Contributor

dvpritzbuer commented Apr 26, 2024

@melloware the change was made in #6109 and should be fine

@datacampsis please try onClick={(e) => (e.target as HTMLInputElement).checked} until 10.6.4 is released

@dvpritzbuer
Copy link
Contributor

@melloware
Tried to find a solution so the user doesn't have to do the cast themself everytime.

The problem is that the underlying react event with target always gets passed EventTarget as target property:
image
image

So the only solution would be to add a specific definition for the onClick method again. Maybe you don't define an additional interface for that and just extend the CheckboxProps interface with onClick?: ( event: React.MouseEvent<HTMLInputElement> & { target: HTMLInputElement } ) => void;

melloware added a commit to melloware/primereact that referenced this issue Apr 26, 2024
@melloware
Copy link
Member

@dvpritzbuer can you review my PR I think I got it right?

@dvpritzbuer
Copy link
Contributor

@melloware
yes, approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typescript Issue or pull request is *only* related to TypeScript definition
Projects
None yet
3 participants