s-yadav / react-number-format

React component to format numbers in an input or as a text.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onValueChanged not called onBlur

soruban opened this issue · comments

Describe the issue and the actual behavior

The docs https://s-yadav.github.io/react-number-format/docs/quirks#notes-and-quirks mention that onValueChanged will be called on Blur but it is not.

Describe the expected behavior

onValueChanged not called onBlur

Provide a CodeSandbox link illustrating the issue

https://codesandbox.io/s/custom-numeric-format-forked-z97sl3?file=/src/App.js

Provide steps to reproduce this issue

Click on the input box, click out, the log statement won't be triggered.

Please check the browsers where the issue is seen

  • Chrome
  • Chrome (Android)
  • Safari (OSX)
  • Safari (iOS)
  • Firefox
  • Firefox (Android)

The onValueChange is only called when the value is changed, either by user input, any prop change or on blur (like removing leading 0 if user typed something like 00100). In this example try typing 0s in front, and then do a blur. You will see it onValueChanged will be called.

If you want to do something onBlur, you can assign event on blur.