Skip to content

Conversation

@buckett
Copy link
Contributor

@buckett buckett commented Dec 9, 2025

CheckboxGroup overrides the onChange value of contained Checkbox components. If a developer incorrectly sets an onChange property on the Checkbox contained within a CheckboxGroup we write a warning to the console in the standard way.

The behaviour is also added to the documentation in the "Guidelines -> Don't" section.

CheckboxGroup overrides the onChange value of contained Checkbox components.
If a developer incorrectly sets an onChange property on the Checkbox contained within
a CheckboxGroup we write a warning to the console in the standard way.

The behaviour is also added to the documentation in the "Guidelines -> Don't" section.
@CLAassistant
Copy link

CLAassistant commented Dec 9, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@matyasf
Copy link
Collaborator

matyasf commented Dec 11, 2025

Thanks for the contribution! We are looking into it

@matyasf matyasf self-assigned this Dec 16, 2025
@matyasf
Copy link
Collaborator

matyasf commented Jan 5, 2026

Can you show a code snippet where "CheckboxGroup overrides the onChange value of contained Checkbox components"? I've got this code:

<FormFieldGroup description={<ScreenReaderContent>CheckboxGroup examples</ScreenReaderContent>}>
  <CheckboxGroup name="sports"
    onChange={function (value) { console.log('group onchange ' + value) }}
    defaultValue={['football', 'volleyball']}
    description="Select your favorite sports"
  >
    <Checkbox label="Football" value="football" onChange={function (value) { console.log('Football CB onchange ' + value) }}/>
    <Checkbox label="Basketball" value="basketball" />
    <Checkbox label="Volleyball" value="volleyball" />
    <Checkbox label="Other" value="other" />
  </CheckboxGroup>
</FormFieldGroup>

and both the group and the individual checkbox event listeners are triggered. In the code I see that they should work, the group clones the checkboxes and safeCloneElement should keep both listeners https://github.com/instructure/instructure-ui/blob/master/packages/ui-react-utils/src/safeCloneElement.ts#L97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants