braintree / restricted-input

Restrict <input>s to certain valid characters (e.g. formatting phone or card numbers)
https://braintree.github.io/restricted-input/
MIT License
68 stars 25 forks source link

Fix Samsung first character selection #28

Closed quinnjn closed 7 years ago

quinnjn commented 7 years ago

Problem reported here: https://github.com/braintree/braintree-web/issues/245

Samsung keyboards when inputting to text input fields reports an incorrect range selection on first entry: {start: 0, end: 1}. This value gets passed through restricted input, and maintained during formatting. The result is the selection highlighting the first character of entry.

This proposal is to always reset the selection range after formatting to the formatted selection end.

Tested this on:

crookedneighbor commented 7 years ago

Tested this on a device that was having problems with the previous bug. Still works great. 👍

crookedneighbor commented 7 years ago

The integration tests were flaky. Kicked them off again and they actually seem to be running now.