JsDaddy / ngx-mask

Angular Plugin to make masks on form fields and html elements.
https://jsdaddy.github.io/ngx-mask
MIT License
1.16k stars 300 forks source link

The numeric value comes with the mask and not in number format #1206

Closed pookdeveloper closed 1 year ago

pookdeveloper commented 1 year ago

🐞 bug report

The numeric value comes with the mask and not in number format:

<input type="text" formControlName="retentionShare" mask="separator.8" thousandSeparator="." class="text-end" />

image

Previous version works: image

Is this a regression?

Yes, it worked in the previous version

Description

the numerical value comes with the mask

🔬 Minimal Reproduction

https://stackblitz.com/edit/stackblitz-starters-4cxfae?file=src%2Fmain.ts

🔥 Exception or Error

🌍 Your Environment

Angular Version: Angular CLI: 16.1.7 Node: 18.16.0 Package Manager: npm 9.5.1 OS: win32 x64

Angular: 16.1.8 ... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic ... router

Package Version

@angular-devkit/architect 0.1601.7 @angular-devkit/build-angular 16.1.7 @angular-devkit/core 16.1.7 @angular-devkit/schematics 16.1.7 @angular/cdk 16.1.7 @angular/cli 16.1.7 @angular/material 16.1.7 @angular/material-date-fns-adapter 16.1.7 @schematics/angular 16.1.7 ng-packagr 16.1.0 rxjs 7.8.1 typescript 5.1.6 webpack 5.88.2 zone.js 0.13.1

Anything else relevant?

andriikamaldinov1 commented 1 year ago

@pookdeveloper thanks for using ngx-mask. here is an example everything works as expected - https://stackblitz.com/edit/stackblitz-starters-t8ku4k?file=src%2Fmain.ts

pookdeveloper commented 1 year ago

@andriikamaldinov1 not works , write 21.34 and it should return numeric not string

andriikamaldinov1 commented 1 year ago

@pookdeveloper I enter the number in input 20,34 because [decimalMarker]=',' and I get the number 20.34. Can you provide example where it return string??

pookdeveloper commented 1 year ago

yes @andriikamaldinov1 https://stackblitz-starters-9uboxj.stackblitz.io image

Thanks! :)

andriikamaldinov1 commented 1 year ago
Screenshot 2023-08-07 at 17 45 36
andriikamaldinov1 commented 1 year ago

@pookdeveloper look at my screenshot, I'm getting a number. What browser are you using ??

pookdeveloper commented 1 year ago

@andriikamaldinov1 Google Chrome

Versión 115.0.5790.170 (Build oficial) (64 bits)

pookdeveloper commented 1 year ago

@andriikamaldinov1 that could be happening? :S I use your stackbliz example and nothing

image

andriikamaldinov1 commented 1 year ago

@pookdeveloper
We tested in different browsers in two versions of chrome: Version 115.0.5790.170 (Official Build) (x86_64) Version 115.0.5790.114 (Official Build) (arm64). The number as on the screenshot above is returned everywhere. It is very difficult to determine your problem, because we get the number.

sebike95 commented 1 year ago

@andriikamaldinov1 You can reproducing the problem if you set your Chrome language to a language that uses "," as decimal marker. I have the same issue, and a stackblitz link is bugged for me too. My Chrome language was hungarian, and we use "," as decimal marker. I've changed my Chrome to english US and it's suddenly works. I briefly took a look the code and figured, that something fishy with currentLocaleDecimalMarker method or the usage of that method. I hope it helps.

andriikamaldinov1 commented 1 year ago

@pookdeveloper @sebike95 Hi. Can you check the new version, does it solve your problem? https://stackblitz.com/edit/angular-95pexu?file=src%2Fmain.ts

andriikamaldinov1 commented 1 year ago

@pookdeveloper @sebike95 Thanks for using Ngx-Mask. If you have any problems in the future please open a new issue with teamplate.