radio as boolean (0, 1) and parseNumbers
oleg-andreyev opened this issue · 4 comments
oleg-andreyev commented
oleg-andreyev commented
atm applied following workaround:
if (props.type === 'radio') {
return (
<ValueEditor
{...props}
handleOnChange={(v) => {
let valuesType = typeof props.values[0].name;
let valueType = typeof v;
if (valueType !== valuesType && valuesType === 'number') {
props.handleOnChange(parseInt(v))
}
}}
/>
);
}
jakeboone02 commented
Thanks for the report. I think your issue might be more with the behavior of native HTML <input>
elements, which always report their value
as a string
, than RQB. What would you propose as a workaround/fix?
oleg-andreyev commented
@jakeboone02 I've added a code-snippet here #622 (comment), I see that we'll see to compare values and value, if values has Int, then value should be casted to Int, and vice-versa.
jakeboone02 commented
Yeah, I saw that but didn't consider it might be the actual solution. Want to submit a PR with that change while I think it over (code is here)? An additional test (radio tests here) will probably be necessary to maintain 100% coverage.