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

InputNumber: issues with decimal separator for some locales, 0s are added to input #9399

Closed
krtek4 opened this issue Oct 12, 2020 · 1 comment
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@krtek4
Copy link

krtek4 commented Oct 12, 2020

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] support request

Plunkr Case (Bug Reports)

https://stackblitz.com/edit/github-2m1zuc

Current behavior

When creating a p-inputNumber for locales that have a different decimal separator for number and currencies, two 0s are padded after each number. This also happens when trying to delete a character with backspace, the number is deleted but two 0s are added to the value.

The issue can be traced back to the fact that the NumberFormat instance does not get the option setting the currency mode in getDecimalExpression : https://github.com/primefaces/primeng/blob/master/src/app/components/inputnumber/inputnumber.ts#L302

Since the "fr-CH" locale has different decimal symbols for numbers and currency (see https://www.localeplanet.com/icu/fr-CH/index.html), the generated regexp is wrong and this causes the issue down the line.

Expected behavior

No additional 0s are added.

Minimal reproduction of the problem with instructions

Add the following input number anywhere : <p-inputNumber mode="currency" currency="CHF" locale="fr-CH"></p-inputNumber>

What is the motivation / use case for changing the behavior?

It is impossible for the user to correctly input an amount.

Please tell us about your environment:

  • Angular version: 10.1.1
  • PrimeNG version: 9.1.3 and 10.1
  • Browser: all
  • Language: all
@krtek4 krtek4 changed the title InputNumber: wrong issues with decimal separator for some locales. InputNumber: issues with decimal separator for some locales, 0s are added to input Oct 12, 2020
@yigitfindikli yigitfindikli added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Nov 25, 2020
@darckyn
Copy link

darckyn commented Jan 14, 2021

Same error here

Locale = pt (pt-br)

Angular 11.0.3
PrimeNG version: 11.1.0

@mertsincan mertsincan self-assigned this Sep 6, 2021
@mertsincan mertsincan added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Sep 6, 2021
@mertsincan mertsincan added this to the 12.1.1 milestone Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

4 participants