jondavidjohn / payform

:credit_card: A library for building credit card forms, validating inputs, and formatting numbers.
https://jondavidjohn.github.io/payform/
Other
427 stars 81 forks source link

Offset caret position when formatting full-width characters #35

Closed ddayguerrero closed 6 years ago

ddayguerrero commented 6 years ago

What is the issue?

Caret position is offset by 1 when credit card number and/or expiry inputs are formatted while typing in full-width. Note that this issue is related to #20.

How to reproduce the issue?

1- Set keyboard to an input source with full-width characters — any Chinese, Japanese, or Korean (CJK) input such as Hiragana will suffice.

2- Use either of the following formatting helpers on a <input> element:

3- Start typing a valid date or credit card value (e.g. 4012 8888 8888 1881)

4- As the value gets formatted (e.g. addition of a whitespace or /), see that the caret position is offset.

How does it affect users?

jondavidjohn commented 6 years ago

Merged the fix and released in 1.2.3