-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Bug]: Checkbox onClick event firing twice not allowing checkboxes to be selected #10122
Comments
Hey @kevinsperrine! Sorry you ran into this. For implementing a controlled checkbox, the function ExampleComponent() {
const [isChecked, setIsChecked] = useState(false);
return <Checkbox checked={isChecked} onChange={setIsChecked} />;
} The I think this is something that would benefit being documented more thoroughly in the storybook. I'll put together a PR. |
@tay1orjones or @sstrubberg In order to work around this I have to add an |
Package
carbon-components-react
Browser
Chrome
Package version
v10.48.0
Description
The onClick event is being fired on both the label and the input causing the checkbox to check and immediately uncheck.
CodeSandbox example
https://react.carbondesignsystem.com/?path=/story/components-checkbox--playground
https://codesandbox.io/s/cool-lederberg-qwoc1?file=/src/index.js
Steps to reproduce
Try to select a checkbox in the playground. https://react.carbondesignsystem.com/?path=/story/components-checkbox--playground
Code of Conduct
The text was updated successfully, but these errors were encountered: