-
-
Notifications
You must be signed in to change notification settings - Fork 262
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
Number mask ignores radix mapping, when value been set directly #863
Comments
@aktanoff i still believe that current behaviour is correct as described in comment there:
Mapping is done only on input. Consider the next example: const m = new MaskedNumber({
thousandsSeparator: '.',
radix: ",",
mapToRadix: ['.'], // note thousandsSeparator is here
scale: 2,
});
m.value = '123.123,23'; // should be resolved as 123123.23 not 123.12 So in |
we experiences same problem today with angular-imask and resolution radix as ','. It's works correctly only for dot '.' radix. problem exist in 6.4.3 More details: when we add 123.00 then visually we can get 12300, but unmask value is correct |
@uNmAnNeR, okay i understood, is there any way to write universal function that sets masked value from 3 forms of sources?:
if i use unmaskedValue to set this, then there is a problem in phone mask like this onAccept gives me unmaksed value like '79998886655', and if i put it into unmasked value, i'm getting '+7(799)988-86-65' value, which is wrong In previous versions, like 6.4.2, it's been working with all 3 sources by just putting values in |
Checked again, my previous message was incorrect, sorry for that Example |
@aktanoff
what you are asking for is probably about setting the value as if the user is typed it. I confirm that's not possible right now. |
@uNmAnNeR, yeah, i think it will be awesome, thank you! |
@aktanoff PR is merged. thank you. but keep in mind that |
@uNmAnNeR, how is it going to work then? |
@aktanoff pretty the same but no return imaskjs/packages/imask/src/masked/base.ts Line 129 in 3fe5d41
|
@aktanoff released. |
Describe the bug
When using default Number mask if i put value with dot radix and numbers after radix, imask ignores the dot, and formats into invalid value
For example
imask.value = '1.23' -> '123'
But if i put in value number that already with comma, imask don't ignore it
imask.value = '1,23' -> '1,23'
Also this bug reproducable when using react-imask library
I've did some research, and i think bug appears because of those changes
672a369#diff-1137652693300b32d70aa6e393b2783596395655a3cd6fb7d70b60c737fab848R118
Lines where code ignores radix mapping
imaskjs/packages/imask/src/masked/number.js
Line 118 in 672a369
So when we manually set value, we getting here with only one flag enabled
input
, andraw
is falsy (undefined)To Reproduce
Here is react example, where you can check that bug exist in hook's setValue, and in direct way by maskRef.current.value = '1.23'
https://codesandbox.io/s/react-imask-input-box-masks-forked-3x3diy?file=/src/index.js
Expected behavior
Radix mapping when we set value directly
Environment:
The text was updated successfully, but these errors were encountered: