ngx-mask: Buggy on Mobile devices

When typing, the cursor moves to a position before the last inserted character (Galaxy S5, Galaxy S7, Moto G4 Play).

In older devices (Galaxy J2 mini), the cursor doesn’t moves as well and all the characters are inserted to the right of the cursor.

You can test it in: https://jsdaddy.github.io/ngx-mask/

Some other plugins, seems to have fixed it by changing the input.selectionStart usage by input.selectionEnd.

As you can see, selectionStart is used here:

https://github.com/JsDaddy/ngx-mask/blob/f83223332b9a462ce9b4863bf185952a5a8f21c3/src/app/ngx-mask/mask.directive.ts#L69

And also used here:

https://github.com/JsDaddy/ngx-mask/blob/f83223332b9a462ce9b4863bf185952a5a8f21c3/src/app/ngx-mask/mask.directive.ts#L76

Related: https://github.com/angular-ui/ui-mask/pull/200

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 26

Most upvoted comments

For numeric input just use input type ‘tel’ like <input type="tel" mask="000 000 000" /> It will work smoothly on mobile devices

This is occurring on Samsung Internet browser

image