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

Negative value do not work for some locale #67

Open
jhasselgren opened this issue Mar 13, 2018 · 0 comments
Open

Negative value do not work for some locale #67

jhasselgren opened this issue Mar 13, 2018 · 0 comments

Comments

@jhasselgren
Copy link

Hi,

I have a problem where the state is not calculated correct for negative values

image

I have found that it is the following code in index.js that is the problem

initialValue = Number(initialValue).toLocaleString(undefined, {
                style                : 'decimal',
                minimumFractionDigits: props.precision,
                maximumFractionDigits: props.precision
            })

The minus sign is change to "−" (‎2212 MINUS SIGN) instead of "-" (‎002D HYPHEN-MINUS)

This result in that the logic for the following line fails

let negativeSignCount = (value.match(/-/g) || []).length;

Because it is looking for "-" (‎002D HYPHEN-MINUS), and in my case where the char is "−" (‎2212 MINUS SIGN) negativeSignCount equals 0, instead of 1

The solution should be to change:

initialValue = Number(initialValue).toLocaleString(undefined, {
                style                : 'decimal',
                minimumFractionDigits: props.precision,
                maximumFractionDigits: props.precision
            })

to

initialValue = Number(initialValue).toFixed(props.precision);
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

1 participant