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

The caret is not moved when typing a decimal separator at an existing decimal separator #711

Closed
2 of 6 tasks
pvdstel opened this issue Dec 8, 2022 · 5 comments
Closed
2 of 6 tasks
Labels

Comments

@pvdstel
Copy link

pvdstel commented Dec 8, 2022

Describe the issue and the actual behavior

Typing one of the characters in allowedDecimals does not update the caret position, if the caret is in front of an already-existing decimal separator.

This is especially noticeable if fixedDecimalScale is enabled, since it forces a decimal to be present.

This error started occurring in 5.1.0.

Describe the expected behavior

If a decimal symbol is typed (any of the allowed decimals) at the same position as an existing decimal sign, the caret should move to the right of the decimal sign, as if the decimal separator was "overwritten" with a new one.

Provide a CodeSandbox link illustrating the issue

https://codesandbox.io/s/alloweddecimalseparators-fixeddecimalscale-bug-epp4d1?file=/package.json

Provide steps to reproduce this issue

Type something like 12%34 in the input field and notice that the decimal sign was never typed.

If the version of react-number-format is downgraded to 5.0.1 it works as expected.

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 Dec 11, 2022

Looks like a bug will check.

@jarekpelczynski
Copy link

Have the same issue

If I have provided these options, pressing dot (.) do nothing

decimalSeparator=","
allowedDecimalSeparators={[".", ","]}
decimalScale={2}

@s-yadav
Copy link
Owner

s-yadav commented Jan 9, 2023

Will check this.

@s-yadav s-yadav added the bug label Jan 9, 2023
@adrian-amigues
Copy link

I confirm having this issue as well, although I notice that the bug seems only present when fixedDecimalScale is true

s-yadav added a commit that referenced this issue Jan 10, 2023
@s-yadav s-yadav mentioned this issue Jan 10, 2023
@s-yadav
Copy link
Owner

s-yadav commented Jan 10, 2023

Fix is available on 5.1.3

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

No branches or pull requests

4 participants