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

Decimal formatting issue with Swedish locales (getSuffix not working) #266

Closed
epbarger opened this issue Nov 17, 2022 · 1 comment
Closed
Labels
wontfix This will not be worked on

Comments

@epbarger
Copy link

Describe the bug
Formatting USD for a Swedish locale (sv, sv-SE) causes zero decimal places to be appended after the suffix.

1.00 becomes 1 US$,00

The Swedish locales sv, sv-SE, etc, use 0xa0 (non breaking space) as the group separator (as returned from the browser). This causes issues with the regex in getSuffix, because the non-breaking space character is also used as the divider between the amount and the suffix. So if you try to format 1.00 USD into a Swedish locale, you end up with 1 USD$,00. If you include a decimal like 1.01, the regex works fine because it's able to match on the decimal separator.

To Reproduce

<CurrencyInputField
  value={"1.00"}
  intlConfig={{locale: 'sv', currency: 'USD'}}
/>

Expected behavior
Formatting 1.00 USD into Swedish locale should end up as 1,00 US$

Additional context
I was able to work around this issue by determining the decimal and group separators outside of this library, and passing them into the CurrencyInputField. If the group separator is a non-breaking space, I convert it to a regular space to get around the issue.

@stale
Copy link

stale bot commented Jan 16, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jan 16, 2023
@stale stale bot closed this as completed Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant