s-yadav / react-number-format

React component to format numbers in an input or as a text.
MIT License
3.88k stars 409 forks source link

onValueChanged not called onBlur #792

Closed soruban closed 1 year ago

soruban commented 1 year ago

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

s-yadav commented 1 year ago

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.