typescript - 需要在 KeyboardAvoidingView 中单击两次,即使 Keyboardshouldpersisttaps 始终为

标签 typescript react-native formik

我正在使用 KeyboardAvoidingView 用键盘向上移动按钮,其中我有一个 ScrollView ,其中 keybordShouldPersistTaps 设置为始终,在 ScrollView 中,我使用 Formik 表单。我仍然需要双击按钮两次才能让键盘关闭并提交我的数据。我一直尝试手动关闭/处理 ScrollView 上的键盘,但没有成功,我应该尝试其他方法吗?

<KeyboardAvoidingView style={{ flex: 1 }} behavior={'padding'}>
    <ScrollView contentContainerStyle={{ flexGrow: 1 }} keyboardShouldPersistTaps={'always'}>
        <Formik
            initialValues={this.state}
            validationSchema={this.schema}
            onSubmit={(values, actions) => {              
              actions.setSubmitting(false);
            }}
            render={({ handleBlur, handleChange, handleSubmit, values, isValid }) => {
              return (
                <View style={onboardingStyles.inputContainer}>
                  <View>
                    <Text theme={theme} style={onboardingStyles.headerText}>
                      {i18n.t('phone_verify')}
                    </Text>
                    <TextInput
                      activeHighlight
                      value={RizeCore.util.formatPhoneDOM(values.phone)}
                      onChangeText={(val: string) => {

                        const phone = RizeCore.util.parseOutDigits(val, 10);
                        return handleChange('phone')(phone);
                      }}
                      onBlur={() => handleBlur('phone')}
                      label={i18n.t('phone_number')}
                      style={onboardingStyles.input}
                      labelStyle={{ color: 'white' }}
                      keyboardType={Platform.OS === 'web' ? 'default' : 'number-pad'}
                      returnKeyType="done"
                    />
                  </View>
                  <BottomFixedCTA
                    ctaLabel={i18n.t('phone_send_code')}
                    loading={smsCodeIsBusy}
                    disabled={!isValid}
                    onPress={handleSubmit as undefined}
                    onBackPress={this._navSignUp}
                  />
                </View>
              );
            }}
          />
        </ScrollView>
      </KeyboardAvoidingView>

最佳答案

尝试使用:

<ScrollView keyboardShouldPersistTaps="handled">

关于typescript - 需要在 KeyboardAvoidingView 中单击两次,即使 Keyboardshouldpersisttaps 始终为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56067862/

相关文章:

javascript - 将数据从两个组件传输到服务( Angular 2)

javascript - 我的简单 react native 项目不会呈现,有什么建议吗?

react-native - 如何使用 REACT-NATIVE-IMAGE-PICKER 从库中选择视频?

javascript - 重新加载页面后立即填写字段

javascript - 如何在 VS Code 中使用 JavaScript 私有(private)字段?

javascript - TypeScript 无法在扩展语法函数调用中推断数组类型

angularjs - 点击后在 map 上奇怪的跳转

android - 在 React Native 应用程序中实现指纹登录

formik - 是的:对象数组的深度验证

reactjs - 在Formik React表单的handleSubmit方法中设置Redux State