diff --git a/src/components/radio.js b/src/components/radio.js index e8277bff7..cfd21ff4d 100644 --- a/src/components/radio.js +++ b/src/components/radio.js @@ -22,6 +22,7 @@ position, margin, error, + filter, } = options; const isDev = B.env === 'dev'; const { GetAll, getProperty, useText, getActionInput } = B; @@ -40,7 +41,13 @@ componentHelperText = useText(helperText); } - const [value, setValue] = useState(componentValue); + componentValue = isNaN(Number(componentValue)) + ? componentValue + : Number(componentValue); + + // maintain the type of the value + const getValue = val => (isNaN(Number(val)) ? val : Number(val)); + const [value, setValue] = useState(getValue(componentValue)); const { FormControl: MUIFormControl, @@ -69,7 +76,7 @@ Radios = renderRadio('value', 'Placeholder'); if (!isDev) { Radios = ( - + {({ loading, error: err, data }) => { if (loading) return Loading...; @@ -88,11 +95,7 @@ } const handleChange = evt => { - // radios modify the type of value - let evtValue = evt.target.value; - // maintain the type of the value - evtValue = isNaN(Number(evtValue)) ? evtValue : Number(evtValue); - setValue(evtValue); + setValue(getValue(evt.target.value)); }; const FormControl = ( @@ -101,7 +104,6 @@ required={required} margin={margin} component="fieldset" - aria-label={label} error={error} > {label} @@ -110,6 +112,7 @@ value={value} name={actionInput && actionInput.name} onChange={handleChange} + aria-label={label} > {Radios} diff --git a/src/prefabs/radio.js b/src/prefabs/radio.js index 4a7ce62c0..d2bfeea1a 100644 --- a/src/prefabs/radio.js +++ b/src/prefabs/radio.js @@ -92,6 +92,21 @@ }, }, }, + { + value: {}, + label: 'Filter', + key: 'filter', + type: 'FILTER', + configuration: { + dependsOn: 'model', + condition: { + type: 'SHOW', + option: 'optionType', + comparator: 'EQ', + value: 'data', + }, + }, + }, { type: 'PROPERTY', label: 'Label Property',