ngx-mask
ngx-mask copied to clipboard
Restore cursor position after dynamic mask changes
🐞 bug report
Is this a regression?
As far as I know, no.
Description
The cursor will jump to the length of extra characters being added in a dynamic mask like +00000000||+(00) 00000000.
So if the user types 12345678, it will be rendered and validated correctly as +12345678. Adding another number will change the value to the format +(12) 3456789 but the cursor will jump to the position between 6 and 7, which is the previous end position plus the extra characters length (( + ) + = 3 spaces) being introduced in the new masked value.
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-ngx-mask-formly?file=src/app/app.component.ts
Using Angular 12 and latest ngx-mask v12.0.0. Happened with previous version as well.