JsDaddy / ngx-mask

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

Trailing Decimal Not Added When mask="separator.1" and leadZero="true" #1358

Closed nathanielbuck closed 1 month ago

nathanielbuck commented 2 months ago

🐞 bug report

Description

I'm not sure if this is a bug or a design decision, but I'd like to have single-decimal auto-completion when no decimal was entered and an input loses focus.

I'm using mask="separator.1" and [leadZero]="true". So, if I type "1" in the input and click/tab out, nothing happens currently. My goal is to have the input value changed to "1.0" in this scenario. (Auto-completion works with mask="separator.2", mask="separator.3", etc.)

This is my first time looking through the source, but it seems like this might be an intentional design decision (if this is indeed is the right spot) as you're checking to see if Number(separatorPrecision) > 1:

https://github.com/JsDaddy/ngx-mask/blob/develop/projects/ngx-mask-lib/src/lib/ngx-mask.service.ts#L714C13-L716C62

πŸ”¬ Minimal Reproduction

<input mask="separator.1" [leadZero]="true" />

https://stackblitz.com/edit/angular-pft6dj?file=src%2Fmain.ts

🌍 Your Environment

Angular Version: 16.2.12

ngx-mask Version: 16.4.2

Angular CLI: 16.2.13
Node: 18.12.1
Package Manager: npm 9.6.7
OS: darwin x64

Angular: 16.2.12
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1602.13
@angular-devkit/build-angular   16.2.13
@angular-devkit/core            16.2.13
@angular-devkit/schematics      16.2.13
@angular/cli                    16.2.13
@schematics/angular             16.2.13
rxjs                            6.6.7
typescript                      4.9.5
zone.js                         0.13.3