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

Mask "0000-M0" is not handled correctly for month. #1298

Closed johanrg closed 2 months ago

johanrg commented 8 months ago

🐞 bug report

The month can not be entered for a date sometimes when formatted as "0000-M0".

Description

As an example, trying to enter the date 1975-01 will only enter 1975-0, the 1 will not be entered.

There is a pattern here that is repeatable for all centuries where the year is greater than or equal to 32, and less than the next decade. As an example 1932 to 1939, 1942 to 1949 and all the way up to 1992-1999. Same with 1732, 1832, 2032 etc.

For each of those dates, only the first number of the month can be inserted.

πŸ”¬ Minimal Reproduction

https://angular-c8dqxg.stackblitz.io

🌍 Your Environment

Angular Version:




@angular-devkit/architect       0.1601.0
@angular-devkit/build-angular   16.1.0
@angular-devkit/core            16.1.0
@angular-devkit/schematics      16.1.0
@angular/cli                    16.1.0
@schematics/angular             16.1.0
rxjs                            7.5.6
typescript                      5.1.6

Anything else relevant?

Using MacOS, tested with Chrome, Firefox and Safari.

andriikamaldinov1 commented 6 months ago

@johanrg Thanks for using Ngx-mask. Please update to latest version. It example all work as expected - https://stackblitz.com/edit/stackblitz-starters-lnx1re?file=src%2Fmain.ts

johanrg commented 6 months ago

Great! Thank you for fixing this bug.

I found a semi-related bug when testing, If you set the attribute [showMaskTyped]="true", it ignores the M0 limitation and allows you to set any value you want.

andriikamaldinov1 commented 6 months ago

@johanrg Could you provide stackblitz with problem? If you u use [showMaskTyped]="true" with this mask u can add [leadZeroDateTime]="true", it will be add zero if month incorrect It example - https://stackblitz.com/edit/stackblitz-starters-4b4jpj?file=src%2Fmain.ts

andriikamaldinov1 commented 2 months ago

This issue has been locked due to inactivity. Please file a new issue by teamplate if you are encountering a similar or related problem.