react-input-mask icon indicating copy to clipboard operation
react-input-mask copied to clipboard

Chrome credit card autocomplete cuts off 3 last digits

Open deflexor opened this issue 2 years ago • 4 comments

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.

deflexor avatar Dec 06 '22 19:12 deflexor

+1

Marbos21 avatar Feb 22 '23 11:02 Marbos21

i have same problem. Do you have any solution?

Omarjcp avatar Feb 27 '23 22:02 Omarjcp

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.

wlannistamps avatar Jun 05 '24 02:06 wlannistamps