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

allowNegativeNumbers combined with separator allows to type multiple zeros at the beginning of value #1238

Closed miszol1 closed 1 year ago

miszol1 commented 1 year ago

🐞 bug report

Description

allowNegativeNumbers combined with separator allows to type multiple zeros at the beginning of value. This behavior does not exists when allowNegativeNumbers = false.

Examples: allowNegativeNumbers = false You can't type 0004.

allowNegativeNumbers = true You can type -0004

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-n1a9gc?file=package.json,src%2Findex.html,src%2Fmain.ts

🌍 Your Environment

Angular Version:



Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1502.1
@angular-devkit/build-angular   15.2.1
@angular-devkit/core            15.2.1
@angular-devkit/schematics      15.2.1
@schematics/angular             15.2.1
ng-packagr                      15.2.2
rxjs                            7.5.6
typescript                      4.8.3

andriikamaldinov1 commented 1 year ago

@miszol1 Thanks for using Ngx-mask. Please update to latest version.

It example all work as expected - https://stackblitz.com/edit/angular-6mfphe?file=src%2Fmain.ts

lucasousi commented 1 year ago

@andriikamaldinov1 Wouldn't the opposite behavior be correct? Why can't we type a leading zero without the value being "pushed"? Think about the case where the user wants to edit a value that was previously 45 to 0.45. They simply won't make it.

miszol1 commented 1 year ago

@lucasousi Yes but if you start typing 0 without . the value is invalid -045

lucasousi commented 1 year ago

@lucasousi Yes but if you start typing 0 without . the value is invalid -045

I opened a thread to discuss this behavior: #1240