react-number-format icon indicating copy to clipboard operation
react-number-format copied to clipboard

Incorrect value returned by `onValueChange` when using empty string `mask` and number in the `format`

Open VanemalP opened this issue 11 months ago • 0 comments

Describe the issue and the actual behavior

When mask is empty string and the format prop includes a number (e.g. +359 ### ### ###), onValueChange callback returns an incorrect value. Instead of only reflecting the user's input, the returned value also includes the static number from the format prop.

Describe the expected behavior

the onInputChange callback should return as value only the user's input, without including the static number from the format prop.

Provide a CodeSandbox link illustrating the issue

https://codesandbox.io/p/sandbox/react-number-format-empty-string-mask-28528j

Provide steps to reproduce this issue

  1. Open the provided CodeSandbox link
  2. Enter any number into the input field.
  3. Observe that the value returned by onInputValueChange includes the static number from the format prop, rather than just the user's input.

Please check the browsers where the issue is seen

  • [x] Chrome
  • [ ] Chrome (Android)
  • [ ] Safari (OSX)
  • [ ] Safari (iOS)
  • [ ] Firefox
  • [ ] Firefox (Android)

VanemalP avatar Jan 20 '25 12:01 VanemalP