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

Inconsistent separator handling #35

Closed
te1 opened this issue Oct 9, 2017 · 3 comments
Closed

Inconsistent separator handling #35

te1 opened this issue Oct 9, 2017 · 3 comments

Comments

@te1
Copy link

te1 commented Oct 9, 2017

Handling of decimal separator doesn't quite work if you want to use a comma instead of a dot.

Steps to reproduce

  • Go to https://kevinongko.github.io/vue-numeric
  • Select "use '.' as separator" (this is the thousand separator)
  • Enter Value "1,2" (with a comma) and leave (blur) input
  • Focus input, it now says "1.2" (with a dot) but should be "1,2" (with a comma)
  • Add 3 to the input and leave (blur) input
  • Value is now 123.0 but should be 1.23

I got it to work by changing the the following

onFocusHandler () {
  this.amount = accounting.formatNumber(this.valueNumber, {
    precision: Number(this.precision),
    decimal: this.decimalSeparator,
    thousand: ''
  })
}

but this breaks #26

@te1
Copy link
Author

te1 commented Oct 10, 2017

It may not be the most elegant solution but this works for me without negative side effects so far:

onFocusHandler () {
  this.amount = this.valueNumber.toString().replace('.', this.decimalSeparator)
}

@wagnereliakim
Copy link

@te1 I found the same problem.
Your las solution works fine, but I think that we can simplify by calling the existing function for this.

onFocusHandler () {
  this.amount = this.format(this.valueNumber)
}

wagnereliakim pushed a commit to wagnereliakim/vue-numeric that referenced this issue Oct 12, 2017
@kevinongko
Copy link
Owner

Should be fixed in 2.2.3

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

3 participants