Skip to content

Commit f2d80c3

Browse files
authored
Merge pull request #448 from data-driven-forms/fix-pf4-radio-again
fix(pf4): fixed radio not being checked.
2 parents 4760ef2 + d305dfc commit f2d80c3

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

packages/pf4-component-mapper/src/files/radio.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ import { useFieldApi } from '@data-driven-forms/react-form-renderer';
44
import { Radio as Pf4Radio } from '@patternfly/react-core';
55
import FormGroup from '../common/form-group';
66

7-
const RadioOption = ({ name, option, isDisabled, isReadOnly, radioGroupValue }) => {
8-
const {
9-
input: { checked, ...input }
10-
} = useFieldApi({ name, value: option.value });
7+
const RadioOption = ({ name, option, isDisabled, isReadOnly }) => {
8+
const { input } = useFieldApi({ name, value: option.value });
119
return (
1210
<Pf4Radio
1311
key={`${name}-${option.value}`}
1412
{...input}
15-
isChecked={radioGroupValue === option.value}
13+
isChecked={input.value === option.value}
1614
value={option.value}
1715
onChange={() => input.onChange(option.value)}
1816
label={option.label}
@@ -51,7 +49,7 @@ const Radio = ({ name, options, type, ...props }) => {
5149
id={id || input.name}
5250
>
5351
{options.map((option) => (
54-
<RadioOption radioGroupValue={input.value} key={option.value} name={name} option={option} isReadOnly={isReadOnly} isDisabled={isDisabled} />
52+
<RadioOption key={option.value} name={name} option={option} isReadOnly={isReadOnly} isDisabled={isDisabled} />
5553
))}
5654
</FormGroup>
5755
);

packages/pf4-component-mapper/src/tests/__snapshots__/form-fields.test.js.snap

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,6 @@ exports[`FormFields should render Radio correctly 1`] = `
862862
"value": "1",
863863
}
864864
}
865-
radioGroupValue=""
866865
>
867866
<Radio
868867
aria-label="One"
@@ -913,7 +912,6 @@ exports[`FormFields should render Radio correctly 1`] = `
913912
"value": "2",
914913
}
915914
}
916-
radioGroupValue=""
917915
>
918916
<Radio
919917
aria-label="Two"
@@ -964,7 +962,6 @@ exports[`FormFields should render Radio correctly 1`] = `
964962
"value": "3",
965963
}
966964
}
967-
radioGroupValue=""
968965
>
969966
<Radio
970967
aria-label="Three"
@@ -2388,7 +2385,6 @@ exports[`FormFields should render disabled Radio correctly 1`] = `
23882385
"value": "1",
23892386
}
23902387
}
2391-
radioGroupValue=""
23922388
>
23932389
<Radio
23942390
aria-label="One"
@@ -2439,7 +2435,6 @@ exports[`FormFields should render disabled Radio correctly 1`] = `
24392435
"value": "2",
24402436
}
24412437
}
2442-
radioGroupValue=""
24432438
>
24442439
<Radio
24452440
aria-label="Two"
@@ -2490,7 +2485,6 @@ exports[`FormFields should render disabled Radio correctly 1`] = `
24902485
"value": "3",
24912486
}
24922487
}
2493-
radioGroupValue=""
24942488
>
24952489
<Radio
24962490
aria-label="Three"

0 commit comments

Comments
 (0)