InputNumber: issues with decimal separator for some locales, 0s are added to input #9399
Labels
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
I'm submitting a ... (check one with "x")
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 ingetDecimalExpression
: https://github.com/primefaces/primeng/blob/master/src/app/components/inputnumber/inputnumber.ts#L302Since 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:
The text was updated successfully, but these errors were encountered: