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/RadioButton: stops working in labels #3054

Closed
AuthorProxy opened this issue Jul 13, 2022 · 10 comments · Fixed by #3055 or #3058
Closed

Checkbox/RadioButton: stops working in labels #3054

AuthorProxy opened this issue Jul 13, 2022 · 10 comments · Fixed by #3055 or #3058
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@AuthorProxy
Copy link

Describe the bug

Checkbox stops working when used inside <label></label> Looks like it handle check event twice, and no visual effect. But if you remove label or press on label (not directly checkbox) everything worked, not worked versions: my 8.1.1, codepen: 8.2.0

Reproducer

https://codesandbox.io/s/primereact-test-forked-d6mnbc

PrimeReact version

8.1.1

React version

17.x

Language

ALL

Build / Runtime

Create React App (CRA)

Browser(s)

Chrome

Steps to reproduce the behavior

No response

Expected behavior

No response

@AuthorProxy AuthorProxy added 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 Jul 13, 2022
@AuthorProxy AuthorProxy changed the title Component: Checkbox stop working in labels Component: Checkbox stops working in labels Jul 13, 2022
@AuthorProxy
Copy link
Author

As a fastfix you can add an onClick handler to label like this:

  const handleLabelClick = useCallback((e) => {
    e.preventDefault();
  });

  <label onClick={handleLabelClick}><Checkbox...></label>

@melloware melloware changed the title Component: Checkbox stops working in labels Checkbox: stops working in labels Jul 13, 2022
@melloware melloware added 👍 confirmed and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jul 13, 2022
melloware added a commit to melloware/primereact that referenced this issue Jul 13, 2022
@melloware melloware self-assigned this Jul 13, 2022
@melloware melloware added this to the 9.0.0 milestone Jul 13, 2022
@melloware
Copy link
Member

Confirmed and thanks for your report. PR submitted.

@AuthorProxy
Copy link
Author

AuthorProxy commented Jul 13, 2022

@melloware may be event.stopPropagation is better? or it doesn't work?

@AuthorProxy
Copy link
Author

@melloware can you make a minor version plz too

@melloware
Copy link
Member

preventDefault seems to work fine vs stopping propagation entirely. I don't work for PrimeTek so this will go out in the next release

@AuthorProxy
Copy link
Author

preventDefault seems to work fine vs stopping propagation entirely. I don't work for PrimeTek so this will go out in the next release

yes, you are right, thks for fast fix

melloware added a commit to melloware/primereact that referenced this issue Jul 13, 2022
@melloware melloware changed the title Checkbox: stops working in labels Checkbox/RadioButton: stops working in labels Jul 13, 2022
@melloware
Copy link
Member

RadioButton has the same issue so I am fixing that too.

@AuthorProxy
Copy link
Author

@melloware @mertsincan still not working at 8.3.0

@melloware
Copy link
Member

@AuthorProxy I just updated your code sandbox to 8.3.0 and its working for me?
Can you try it? See: https://codesandbox.io/s/primereact-test-forked-t00ctf

@AuthorProxy
Copy link
Author

@AuthorProxy I just updated your code sandbox to 8.3.0 and its working for me? Can you try it? See: https://codesandbox.io/s/primereact-test-forked-t00ctf

Yes - everything works, probably something was cached when I tested it.

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
3 participants