Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

is there a way to not dismiss the keyboard when closing parent component in react native

$
0
0

I am currently opening the keyboard automatically as soon as the parent component or the modal is visible, which is what I want but the problem is that when I dismiss the modal first the keyboard will be dismissed, and then the modal will be dismissed which is causing bad UI interactivity. I would like to keep the keyboard still and only dismiss the parent component or the modal instead of both. I am using scrollView inside KeyboardAvoidingView while keyboardShouldPersistTapsis set to "always". you can find my code below:

    const amountInput = () => (<View style={styles.inputAndTextContainer}><Text style={styles.textStyle}>ETB</Text><TextInput        onKeyPress={({ nativeEvent }) => {          return nativeEvent.key === 'Backspace' ? clearLastChar() : null;        }}        caretHidden        ref={textInputRef}        style={styles.inputStyle}        autoCapitalize="none"        autoCorrect={false}        keyboardType="numeric"        defaultValue={amount.value}        /* value={amount.value} */        autoFocus        maxLength={6}        onChangeText={num => {          setAmount({ value: addCommaToNumber(num) });        }}      /></View>  );   return (<View><Modal        isVisible={isVisible}        animationIn="bounceInUp"        animationOut="slideOutDown"        animationOutTiming={200}        animationInTiming={200}        style={{ margin: 0 }}><KeyboardAvoidingView behavior="padding"><Header /><ScrollView            keyboardShouldPersistTaps="always"            alwaysBounceVertical={false}>            {amountInput()}            {state && state.length ? someFunc() : anotherFunc()}</ScrollView>          {renderModal()}          {state ? someFunc() : someotherfunc()}</KeyboardAvoidingView></Modal></View>    )

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>