Skip to content

Changing a number field from 11 to 1 will fail to render the new valueΒ #2157

@captain-geek

Description

@captain-geek

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)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions