react-stripe-elements icon indicating copy to clipboard operation
react-stripe-elements copied to clipboard

Stripe element gets focus if error occurred in createToken(...)

Open zhdanouskikh opened this issue 6 years ago • 2 comments

I'm using CardElement component. When I'm trying to call stripe.createToken(...) and get error (user didn't enter cvc for example) component is autofocused. I do not expect such behaviour, cause stripe input is the last one, and there are inputs that needs to be focused instead stripe if there was an error.

Does someone have thoughts how I can disable autofocus?

zhdanouskikh avatar Feb 11 '20 14:02 zhdanouskikh

@zhdanouskikh, you should be able to override this behavior by sending the focus wherever you like after stripe.createToken has resolved. Take a look at this example:

https://codesandbox.io/s/trusting-worker-ehxnv?fontsize=14&hidenavigation=1&theme=dark

Let me know if this doesn't work for you.

dweedon-stripe avatar Feb 12 '20 13:02 dweedon-stripe

Closing this as this project has migrated to React Stripe.js. If you believe this is still important, please re-open it there.

sashko-stripe avatar Mar 26 '21 19:03 sashko-stripe