-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CheckboxGroupInput overrides the type of the selected value #6516
Comments
Until I figure out why we have this, you can override the behavior using the |
I'm sorry, I fail to understand how to reproduce this. Could you please elaborate and show the application code you're using? |
Hello. This problem has surfaced again in the project.
|
Faced the same problem. In my case id field could contain large numbers and in case of 16 digits or higher CheckboxGroupInput changed its value! For id = '81999999999999999' the control picked up value 82000000000000000, and for '8199999999999999899999' - even 8.2e+21. In case of using alphanumeric id - the problem does not appear. It is also not clear how to use 'parse' parameter to work around the problem. |
Reproduced. Thanks |
I hadn't read the entire conversation. @fzaninotto, const handleCheck = useCallback(
(event, isChecked) => {
+ const newValue = event.target.value;
- let newValue;
- try {
- // try to convert string value to number, e.g. '123'
- newValue = JSON.parse(event.target.value);
- } catch (e) {
- // impossible to convert value, e.g. 'abc'
- newValue = event.target.value;
- }
// ...
},
[finalFormOnChange, finalFormOnBlur, value]
); |
What you were expecting:
As a backend I use a GraphQLServer. in it, the values of all fields are strongly typed. The type specified for the resource identifier is String.
For selection inside the
CheckboxGroupInput
, the backend returned one of options with a record{id: "54367564", ///...}
. When I chose this option and sent the mutation to the server, it gave me a type error.It turned out that instead of a string value, the input converted the identifier to a number.
What happened instead:
Expected
CheckboxGroupInput
to leave the identifier unchangedSteps to reproduce:
{id: "54367564", ///...}
{ids: [54367564, ...]}
entry as the value in the dataproviderRelated code:
here is a piece of code
CheckboxGroupInput
that does it.In my use case, I don't understand why it is needed
The text was updated successfully, but these errors were encountered: