sanniassin / react-input-mask

Input masking component for React. Made with attention to UX.
MIT License
2.24k stars 255 forks source link

Chrome credit card autocomplete cuts off 3 last digits #303

Open deflexor opened 1 year ago

deflexor commented 1 year ago

Hi, i have input field for credit card autoComplete="cc-number" and the mask for it mask={'9999 9999 9999 9999'}. Typing in number or pasting it works very well, but chrome has feature to autocomplete stored card information. And in this case 3 last digits of card number got missing. It looks like this (console.log in beforeMaskedStateChange):

currentstate.value -> nextstate.value
1234123412341234 -> 1234 1234 1234 1234
1234 1234 1234 1234 -> 1234 1234 1234 1234
1234 1234 1234 1234 -> 1234 1234 1234 1234
1234123412341234 -> 1234 1234 1234 1
1234 1234 1234 1 -> 1234 1234 1234 1
1234 1234 1234 1 -> 1234 1234 1234 1

So it looks like last digits got missing because of 3 spaces added, but why beforeMaskedStateChange is called so many times, and while pasting 1234123412341234 from clipboard it works just well.

Marbos21 commented 1 year ago

+1

Omarjcp commented 1 year ago

i have same problem. Do you have any solution?

wlannistamps commented 5 months ago

I am running into TypeError: Cannot read properties of undefined (reading 'value') on the beforeMaskedStateChange() function, @deflexor would you mind pasting in what your console looks like? Might help me to understand how this is supposed to work more.