JsDaddy / ngx-mask

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

Cursor improperly jumps when decimalMarker is set #1406

Closed lucasousi closed 1 month ago

lucasousi commented 4 months ago

🐞 bug report

Is this a regression?

Able to reproduce in 16.4.0 and 17.1.8

Description

When typing a formatted number with a decimalMarker, the cursor unexpectedly jumps to the wrong position after deleting characters.

Steps to Reproduce:

 <input name="with-bug" mask="separator.2" decimalMarker="," thousandSeparator="." />

Expected Result: The cursor should remain to the left of the comma.

Actual Result: The cursor jumps to the right of the comma.

Additional Information:

<input name="without-bug" mask="separator.2" thousandSeparator="." />

Impact: This bug affects the user experience by causing confusion and errors in number input fields.

πŸ”¬ Minimal Reproduction

https://stackblitz.com/edit/ngx-mask-cursor-jumping

🌍 Your Environment

Angular Version: 18.0.0


Angular CLI: 18.1.1
Node: 18.20.3
Package Manager: npm 10.2.3
OS: linux x64

Angular: 18.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1801.1
@angular-devkit/build-angular   18.1.1
@angular-devkit/core            18.1.1
@angular-devkit/schematics      18.1.1
@schematics/angular             18.1.1
rxjs                            7.8.1
typescript                      5.4.5
zone.js                         0.14.8

Anything else relevant?

andriikamaldinov1 commented 1 month ago

@lucasousi
Thanks for using Ngx-mask. Please update to latest version. It example all work as expected - https://stackblitz.com/edit/stackblitz-starters-ywyjwa?file=src%2Fboot.module.ts,src%2Fboot.component.ts