React-Native 中的 TextInput 奇怪行为 [英] TextInput weird behaviour in React-Native

查看:39
本文介绍了React-Native 中的 TextInput 奇怪行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 TextInput,

<TextInput
        style={[
          styles.inputField,
          isEmailError && { borderColor: color.delete },
        ]}
        placeholder={'E-mail'}
        placeholderTextColor={color[colorScheme].textMuted}
        autoCapitalize={'none'}
        autoCorrect={false}
        value={userCredentials.email}
        onChangeText={onChangeEmail}
        onSubmitEditing={passwordInput.current && passwordInput.current.focus}
        blurOnSubmit={false}
        returnKeyType={'next'}
        keyboardType="email-address"
/>

当我点击键盘外的任何其他地方(比如一个按钮)时,预期的行为是按钮会被点击,但是,在这里,第一次点击总是关闭键盘然后我必须再次按下我的任何元素试图到达.

When I click anywhere else outside the keyboard(let's say a button), the expected behaviour is that the button will get clicked, however, in here, first click always closes the keyboard then I have to press again for whatever element i was trying to reach.

推荐答案

这是因为滚动视图.在滚动视图中添加道具 keyboardShouldPersistTaps 如下以解决错误:

This is because of scroll view. Add props keyboardShouldPersistTaps in your scrollview as below to solve error :

<ScrollView
    keyboardShouldPersistTaps="handled"
    keyboardDismissMode="interactive"
>

...
...

</ScrollView>

您可以在此处

这篇关于React-Native 中的 TextInput 奇怪行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆