uNmAnNeR / imaskjs

vanilla javascript input mask
https://imask.js.org
MIT License
4.96k stars 258 forks source link

Number truncated (or not) depending currencySymbol position (num$ or $num) #1071

Open Jbo31 opened 2 months ago

Jbo31 commented 2 months ago

Describe the bug I use imask to format monetary values depending on the locale.

I have a non consistent behaviour depending on the used mask.

Let's assume I have an input fill with 123456.

I will two masks versions : V1:RightSymbolPosition{ mask: 'num€', } V2:LeftSymbolPosition{ mask: '$num',

On the V1 version, 123456€ is displayed. Insert '7' between 3 and 4. It will result in : 1237. "456" has been truncated. (Would expect 1237456)

On the V2 version, $123456 is displayed. Insert '7' between 3 and 4. It will result in : 1237456. No truncate.

Depending the position of my currency symbol, behaviour is not consistent. I would expect for V1 to avoid truncating the end of the value. Would expect to have 1237456.

To Reproduce Open : https://codepen.io/Jbo31/pen/dyBKNjO Insert '7' between 3 and 4, in the 2 inputs, result is not consistent.

Will result in 1237 or 1237456 depending the cursor position.

Expected behavior For that mask 'num€', I would expect not truncating the end of the number. 123456€ is displayed. Insert '7' between 3 and 4. Would expect 1237456

Environment: