Bug - Data List Checkbox can't be checked #6997
Answered
by
kmcfaul
nmp1testing
asked this question in
Q&A
-
|
The checkbox(es) of the Data List Checkbox example can't be checked. Is there a working example of this component? |
Beta Was this translation helpful? Give feedback.
Answered by
kmcfaul
Sep 9, 2024
Replies: 1 comment 1 reply
-
|
try adding defaultChecked attribute to the component Below is an example:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue is that
DataListCheckdoesn't handle uncontrolled checkboxes, and examples of are not fully wired up to handle checkbox events. You would need track the checked state in the app state, pass that tocheckedonDataListCheckas well as pass an event handler toonChangeto toggle the checked state.<DataListCheck checked={isCheckedState} onChange={onChangeHandler} aria-labelledby="check-action-item1" name="check-action-check1" />There is a PR open for
DataListtargeting the next major version (v6) that will resolve the issue with uncontrolled checkboxes not functioning, so the behavior will work by default and you won't need to wire up the example.