-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
Description
Prerequisites
- I have searched the existing issues
- I understand that providing a SSCCE example is tremendously useful to the maintainers.
- I have read the documentation
- Ideally, I'm providing a sample JSFiddle, Codesandbox.io or preferably a shared playground link demonstrating the issue.
What theme are you using?
antd
Version
5.x
Current Behavior
The issue can be reproduced in the RJSF playground, https://rjsf-team.github.io/react-jsonschema-form/, by changing to the "number" examples.
When the user enters a numerical value followed by a dot, the value from formData
is removed completly.
Looking at the NumberField.tsx code (https://github.com/rjsf-team/react-jsonschema-form/blob/main/packages/core/src/components/fields/NumberField.tsx) there's some special handling for such cases:
/**
* The NumberField class has some special handling for dealing with trailing
* decimal points and/or zeroes. This logic is designed to allow trailing values
* to be visible in the input element, but not be represented in the
* corresponding form data.
*
* The algorithm is as follows:
*
* 1. When the input value changes the value is cached in the component state
*
* 2. The value is then normalized, removing trailing decimal points and zeros,
* then passed to the "onChange" callback
*
* 3. When the component is rendered, the formData value is checked against the
* value cached in the state. If it matches the cached value, the cached
* value is passed to the input instead of the formData value
*/
but from my understanding of point 2 the normalized value should be stored in in the formData
object, which is not the case.
Expected Behavior
Proper value is saved in the formData state.
Steps To Reproduce
- Navigate to the RJSF e=playground and change to the "Numbers" example
- Type "123" in the "Number" field
formData
properly reflects the change- Type "123." in the "Number" field
formData
no longer holds the value form the field
Environment
Anything else?
No response