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 257 forks source link

ctrl+v #183

Open k-one-o-two opened 8 years ago

k-one-o-two commented 8 years ago

Pasting into fields with a mask now puts the cursor into the correct place.

The issue: if there is a field like this <input type="text" ui-mask="39.19.2999" placeholder="__.__.____" ng-model="data.birthDate"/> and you paste 26091987 into it the resulting value would be 26.09.1987 which is correct.

But the caret position is in the wrong place - before the "87". It's because masked value is 2 digits longer then the unmasked.

This PR fixes the issue.

However I don't know how to write a test for that: selectionStart always returns the end (10 in this case), so I'd be happy if you pointed me how to do this.