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.
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
vsinput.selectionEnd
. When you are trying to get the caret position, you were using theinput.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.