Skip to content
11 changes: 5 additions & 6 deletions static/src/js/components/CustomRadioWidget/CustomRadioWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ const CustomRadioWidget = ({

// Sets inputValue to input selected
const handleChange = (event) => {
const { name } = event.target
const newValue = name === 'true'

const { id: targetId } = event.target
const newValue = targetId.endsWith('-true')
onChange(newValue)
}

Expand Down Expand Up @@ -100,7 +99,7 @@ const CustomRadioWidget = ({
<input
className="d-flex form-check-input m-2"
id={`${id}-true`}
Copy link
Contributor

@eudoroolivares2016 eudoroolivares2016 Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the id values duplicates? I'm kind of confused why the name would be used here or contain the id value since the name should be what is on the view/display. If its on the same widget since that's the prop coming from the parent maybe we can append another part to the id value in each of the inputs or pass down a little more information where this gets rendered from

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik this is being required by react-json-schema form, otherwise the form itself gets out of sync with the json data.

name="true"
name={`${id}-true`} // Note: react-jsonschema-form requires these name properties to be unique.
onChange={handleChange}
type="radio"
checked={value === true}
Expand All @@ -114,8 +113,8 @@ const CustomRadioWidget = ({
>
<input
className="form-check-input m-2"
id={`${id}-false`}
name="false"
id={`${id}-false`} // Note: react-jsonschema-form requires these name properties to be unique.
name={`${id}-false`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to tack on -false to make it unique.

onChange={handleChange}
type="radio"
checked={value === false}
Expand Down