taiga-family/maskito

๐Ÿž - Incorrect format with thousandSeparator = "."

spellier opened this issue ยท 1 comments

Which package(s) are the source of the bug?

@maskito/core

Playground Link

https://stackblitz.com/edit/wthvqt?file=index.ts

Description

thousandSeparator : ' . '
decimalSeparator : ' , '
decimalZeroPadding : true,
precision : 2,

Mask pre-filled with a value from JSON : 123456.789

When :
const value = maskitoTransform('123456.789', maskitoOptions);

Excepted :
123.456,78

Result :
123.456.789,00

Maskito version

2.3.0

Which browsers have you used?

  • Chrome
  • Firefox
  • Safari
  • Edge

Which operating systems have you used?

  • macOS
  • Windows
  • Linux
  • iOS
  • Android

@spellier Hello!

Unfortunately, your case is rather controversial.
It does not have truly right answer.

You pass point as thousandSeparator.
Maskito gets 123456.789. It interprets point inside passed value as thousand separator.
Maskito just add other missing thousand separators and then enable zero padding.

if you want to get different behavior โ€“ just pass point as decimalSeparator and something else (except point) as thousandSeparator.

It is expected behaviour for Number-mask.
I am going to close this issue.