-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Changing a number field from 11 to 1 will fail to render the new value #2157
Comments
…eam#2157) Use a ^ to ensure regex matches the entire new value and not just the end of the value. Normalize the cache value with a leading zero when it starts with a decimal character as is done in handleChange. Co-authored-by: Landon Bradshaw <landon.bradshaw@gmail.com>
…eam#2157) Use a ^ to ensure regex matches the entire new value and not just the end of the value. Normalize the cache value with a leading zero when it starts with a decimal character as is done in handleChange. Co-authored-by: Landon Bradshaw <landon.bradshaw@gmail.com>
…eam#2157) Use a ^ to ensure regex matches the entire new value and not just the end of the value. Co-authored-by: Landon Bradshaw <landon.bradshaw@gmail.com>
…eam#2157) Use a ^ to ensure regex matches the entire new value and not just the end of the value. Normalize the cache value with a leading zero when it starts with a decimal character as is done in handleChange. Co-authored-by: Landon Bradshaw <landon.bradshaw@gmail.com>
…eam#2157) Use a ^ to ensure regex matches the entire new value and not just the end of the value. Normalize the cache value with a leading zero when it starts with a decimal character as is done in handleChange. Co-authored-by: Landon Bradshaw <landon.bradshaw@gmail.com>
…eam#2157) Use a ^ to ensure regex matches the entire new value and not just the end of the value. Normalize the cache value with a leading zero when it starts with a decimal character as is done in handleChange. Co-authored-by: Landon Bradshaw <landon.bradshaw@gmail.com>
@jacqueswho @epicfaace - I notice that the suggested Regex by @captain-geek , has not been merged to main branch. Our team is using this library too, and we noticed that when let's say text field is given a number '10', any number that starts with '10' and ends with '10' will not reset when we do router.replace (reset implying that the field returns to its original/default value). I know, I've reported this in a vague way, but the question is, have this solution been merged to master/main ? |
@leology will discuss with the team on Friday, hopefully get this in on the next release, since its a small change |
So after trying it with 5.x it seems that only the |
Also getting this issue on the project I'm working on. The issue is easily reproducible in the playground. Any updates on this? Would appreciate if a fix could be merged. Thank you! |
@maximecote57 Given that the main maintainers of the project are volunteers who generally only have a few hours a week to focus on things, most of the corner-case issues aren't generally a high priority. Would you be willing to provide the fix in a PR? I believe that the solution provided above may work as is. Thanks for understanding |
Unfortunately the above solution makes some tests break so I'm not sure it's the correct solution. I'll try to find some time to investigate later this week. Thank you! |
@maximecote57 if you have any questions, feel free to ask them here |
In our project we were using a form that contained a number input, we noticed that if we changed the form value from 11 to 1 the field would continue to show 11 when the formData held 1
The pattern was confirmed with 420 and 20, or 17 and 7, 1234 and 234 ...
The error lies in the following line of code:
react-jsonschema-form/packages/core/src/components/fields/NumberField.js
Line 76 in c9d0569
If you change it to:
the field will render correctly when the value changes
(note the
"^"
added to the beginning of the regex so that it has to match the full string value, not just the right side of the value)The text was updated successfully, but these errors were encountered: