ngx-mask
ngx-mask copied to clipboard
Directive on text input with mask: separator.0 + leadZero=true changes numeric form control type to string
🐞 bug report
Is this a regression?
No
Description
When using mask directive with expression: separtor.N (for example: separator.0) with flag [leadZero]=true and using Angular Reactive Forms, a form control is changing it's type from number to string. It's caused by the method _toNumber: It checks if it's a SEPARATOR expression and if leadZero is truthy. Why is that? I think the form control type shouldn't be changed via mask. Especially by the SEPARATOR expression mask which should be always a number? Is this a desired behaviour?
My problem is that if a user is typing for example 23 in an input, the control.valueChanges output is "23" string, but should be a number.
this.control.valueChanges.subscribe(console.log) // <--- displays "23" string instead of 23 number
🔬 Minimal Reproduction
<input
mask="separator.0"
[leadZero]="true"
formControlName="myNumericFormControl"
/>
🌍 Your Environment
Angular Version:
latest