Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't type decimals after erase them when maxLength and fixedDecimalScale is provided #758

Closed
nicolas-c-dev opened this issue May 16, 2023 · 2 comments

Comments

@nicolas-c-dev
Copy link

Describe the issue and the actual behavior

Setting a NumericFormat with fixedDecimalScale and a maxLength value if you type a value with decimals, erase decimals recently typed and then try to type another decimals, nothing happens. The new decimals can't be typed

Describe the expected behavior

Can be able to replace the decimal values typed

Provide a CodeSandbox link illustrating the issue

https://codesandbox.io/s/magical-sid-l65u8t?file=/src/App.js

Provide steps to reproduce this issue

Try to replace the "4" with another number

Please check the browsers where the issue is seen

  • [ ✔️] Chrome
  • [ ✔️] Chrome (Android)
  • [ ✔️] Safari (OSX)
  • [ ✔️] Safari (iOS)
  • [ ✔️] Firefox
  • [ ✔️] Firefox (Android)
@s-yadav
Copy link
Owner

s-yadav commented Aug 13, 2023

While this is valid case, it can't be fixed. As formatting happens post the number is typed. In this case maxLength doesn't allow to type at all, if the number of characters is over the defined length, so rnf can't do anything in this case.

To fix this you can use isAllowed prop. Updated sandbox.
https://codesandbox.io/s/bug-react-number-format-forked-6w93jr

@s-yadav s-yadav closed this as completed Aug 13, 2023
@s-yadav
Copy link
Owner

s-yadav commented Aug 13, 2023

I will also mention this on document, for future reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants