Open oleg-andreyev opened 10 months ago
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))
}
}}
/>
);
}
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?
@jakeboone02 I've added a code-snippet here https://github.com/react-querybuilder/react-querybuilder/issues/622#issuecomment-1872126396, 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.
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.
Right now experiencing issue with radio element, which holds boolean (0, 1).
As soon I save and render components once again I see and non-values are selected
UPD
Noticed that values
name
is string, that's why it cannot match.but as soon as change type to int, types are swapped in
value
initial load as soon I click on radio