-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
masked method work incorrectly with unmasked results #249
Comments
#225 - If I understand correctly, in both cases, the masked handles the float attribute value as an integer: what is incorrectly or not expected. |
question here: should @rozsazoltan - it is number (float), not integers. and it lost fraction |
I think problem, that for |
Yes, it's a known issue with some locales. You can pass initially formatted value as a workaround: mask.masked(Intl.NumberFormat({ locale: 'pt-BR' }).format(10234.54)) // = 10.234,54 |
Yes, but why |
const mask = new Mask({ number: { locale: 'pt-BR', fraction: 2 } })
Intl.NumberFormat('pt-BR').format(10234.54) // 10.234,54
mask.masked('10.234,54') // 10.234,54 - same, just waste cpu time as I understand, expectation: const number = 10223.34
const numberAsStr = number.toString() // '10223.34'
mask.masked('10223.34') // should return '10.223,34', but not working
mask.unmasked('10.223,34') // should return '10223.34', so parseFloat('10223.34') => 10223.34 and this is not happening now |
Yeah, it’s currently not working with locales that have dot as separator. If you have a universal solution for parsing all locales, PR are welcome. |
@beholdr I think stuff like "parsing" and "formating" need to be split, so parsing can work with normal numbers (not only based on locale), while "formating" do format based requested locale |
@le0pard I agree with that, but it’s more complicated. Problem is not to parse a correctly formatted number like |
Describe the bug
All inputs have activated number mask with local
pt-BR
. Last input calculate sum for all other inputs and have mask too:This lead that number incorrectly masked in total field. Instead of
10.34
it get1034
. So this mean:Steps to reproduce
Reproduction link
Example
The text was updated successfully, but these errors were encountered: