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

Keyboard cannot be dismissed for CardForm component

Open JulianErnest opened this issue 3 years ago • 9 comments

Describe the bug Keyboard cannot be closed by tapping away from the screen. I've programmatically called Keyboard.dismiss() however this works for other inputs but not for the CardForm inputs.

To Reproduce Steps to reproduce the behavior:

  1. Add CardField component
  2. Open any of the inputs

Expected behavior Keyboard should easily be dismissed

Additional context I've already followed the solution from: https://github.com/stripe/stripe-react-native/issues/222 however this does not work for CardForm

JulianErnest avatar May 21 '22 04:05 JulianErnest

Is this on Android or iOS? or both?

Filling out the entire bug report template is a huge help to us in debugging the issue

charliecruzan-stripe avatar May 24 '22 17:05 charliecruzan-stripe

This is for iOS. It's basically the same issue with #222, however for CardForm that's why I didn't get too detailed about it, apologies.

JulianErnest avatar May 25 '22 09:05 JulianErnest

Using StripeContainer only works if I wrap the entire screen. So, I found another ugly workaround. Create a 1x1 text input that you can focus to kill the keyboard. 🙄

const MyComponent = () => {
  const closeKeyboard = useCallback(() => {
    focusInputRef.current.focus();
    Keyboard.dismiss();
    focusInputRef.current.blur();
  }, []);
  
  return (
    <View>
      <CardForm />
      <TextInput
        ref={focusInputRef}
        accessible={false}
        accessibilityElementsHidden={true}
        style={styles.hackFocusInput}
      />
    </View>
  )
}
const styles = {
  hackFocusInput: {
    width: 1,
    height: 1,
    position: 'absolute',
    bottom: 0,
    right: 0,
    opacity: 0,
  },
}

Using<StripeContainer /> also works, but I have to wrap the entire screen with it.

jgillick avatar Apr 06 '23 00:04 jgillick

Same issue here but only with Zipcode. Urgent to fix this.

manishnaruka avatar Mar 11 '24 20:03 manishnaruka