JsDaddy / ngx-mask

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

FormControl type number since 13.1.10 #1303

Closed louis-neologix closed 6 months ago

louis-neologix commented 8 months ago

🐞 bug report

Is this a regression?

Yes, the previous version in which this bug was not present was: 13.1.9

Description

I just upgraded a projet from angular 12 to 13 and ngx-mask as well. Before the upgrade, when I had a masked input with "separator.2", my formcontrol got string values. For example, when i entered "55.0" in my input, my formcontrol's value was "55.0" with string type. Since the upgrade (and more precisely between 13.1.9 and 13.1.10), my formcontrol's value now receives the value 55 with number type.

I don't know if this is intentional but for me it is problematic as I need to keep the precision of the entered value.

🔬 Minimal Reproduction

I tried to create a stackblitz to show the problem but there's a compilation error (maybe because of #981) :worried:

https://stackblitz.com/edit/angular-13-starter-project-ubncdb

🌍 Your Environment

Angular Version:


    "@angular/animations": "13.4.0",
    "@angular/common": "13.4.0",
    "@angular/compiler": "13.4.0",
    "@angular/core": "13.4.0",
    "@angular/forms": "13.4.0",
    "@angular/platform-browser": "13.4.0",
    "@angular/platform-browser-dynamic": "13.4.0",
    "@angular/router": "13.4.0",
    "ngx-mask": "13.1.10",
    "rxjs": "6.5.3",
    "tslib": "2.4.0",
    "zone.js": "0.11.6"
andriikamaldinov1 commented 6 months ago

@louis-neologix Thanks for using Ngx-mask. We have changed the behavior in recent versions, but we have added the ability to transpose values. inputTransfromFn => change model and input value outputTransfromFn => change only in model

It example - https://stackblitz.com/edit/angular-13-z3bny2?file=src%2Fapp%2Fapp.module.ts,src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.ts

You can write your own function that will return the value you need.