- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.3k
 
Closed
Labels
Description
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:
| const re = new RegExp(`${value}`.replace(".", "\\.") + "\\.?0*$"); | 
If you change it to:
const re = new RegExp(`^${value}`.replace(".", "\\.") + "\\.?0*$");
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)
maximecote57