Skip to content

Commit 098ee83

Browse files
authored
MMT-4038: Fix issue where one input was affecting another on the form (#1423)
* MMT-4038: Fixed issue when toggling radio button to true/false.
1 parent 46ac4b9 commit 098ee83

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

static/src/js/components/CustomRadioWidget/CustomRadioWidget.jsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ const CustomRadioWidget = ({
6969

7070
// Sets inputValue to input selected
7171
const handleChange = (event) => {
72-
const { name } = event.target
73-
const newValue = name === 'true'
74-
72+
const { id: targetId } = event.target
73+
const newValue = targetId.endsWith('-true')
7574
onChange(newValue)
7675
}
7776

@@ -100,7 +99,7 @@ const CustomRadioWidget = ({
10099
<input
101100
className="d-flex form-check-input m-2"
102101
id={`${id}-true`}
103-
name="true"
102+
name={`${id}-true`} // Note: react-jsonschema-form requires these name properties to be unique.
104103
onChange={handleChange}
105104
type="radio"
106105
checked={value === true}
@@ -114,8 +113,8 @@ const CustomRadioWidget = ({
114113
>
115114
<input
116115
className="form-check-input m-2"
117-
id={`${id}-false`}
118-
name="false"
116+
id={`${id}-false`} // Note: react-jsonschema-form requires these name properties to be unique.
117+
name={`${id}-false`}
119118
onChange={handleChange}
120119
type="radio"
121120
checked={value === false}

0 commit comments

Comments
 (0)