angular-ui / ui-mask

Mask on an input field so the user can only type pre-determined pattern
https://htmlpreview.github.io/?https://github.com/angular-ui/ui-mask/master/demo/index.html
MIT License
391 stars 258 forks source link

Fixed issue with input on Android devices putting cursor behind the input. #200

Closed travist closed 1 year ago

travist commented 7 years ago

This seems to be fixing the same thing as https://github.com/angular-ui/ui-mask/pull/191 but does so with what seems MUCH less changes.

I realized that on my Samsung Galaxy S6 device, that any input (such as your phone number input on your demo site) the cursor would end up getting behind the input. I finally debugged the issue and realized that my device is actually "selecting" the character that is being input. What happens is this causes a different value for the input.selectionStart vs input.selectionEnd. When you are trying to get the caret position, you were using the input.selectionStart which ends up being at the beginning of the input character (which causes this issue).

It seems that you can solve all use cases by changing this to input.selectionEnd which will give you the end of any selection and the correct caret position.

onepointcw commented 7 years ago

I'am very interested by this fix. This will be released soon ?

Thanks.

samshay commented 7 years ago

When this branch going to be merge ???