【问题标题】:react-native Keyboard.dismiss() not working after autofill on iOS在iOS上自动填充后react-native Keyboard.dismiss()不起作用
【发布时间】:2020-05-02 19:05:34
【问题描述】:

我正在使用 expo 开发一个 react-native 应用程序。

在我的登录屏幕上,我确实有两个 TextInput(带有 textContentType 用户名和密码)。 我确实有多个地方可以调用Keyboard.dismiss()(来自包装的Touchable,来自其他按钮等),这对于大多数用例都适用。

我的问题是,在我在 iOS 上成功使用密码自动填充(通过指纹)后,首先键盘隐藏并自动重新显示(触发所有常见的键盘事件),这看起来很奇怪,但可以接受,但之后键盘不再对任何内容做出反应Keyboard.dismiss() 调用,直到我关注另一个 TextInput。

“使用强密码”键盘覆盖似乎存在类似问题。

这是我的版本:

"expo": "^34.0.1",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",

在 iOS 13.2.3 的 Expo 客户端中运行

提前感谢您的帮助。

编辑:

我将问题简化为最基本的版本。在我在 iOS 设备上使用密码自动填充之前,关闭按钮可以正常工作。

https://github.com/SebastianRoese/tryouts/tree/master/keyboard-dismiss-problem

import React from 'react'
import { View, Button, TextInput, StyleSheet, Keyboard } from 'react-native'

const App = () => {
    return (
        <View style={styles.screen}>
            <TextInput style={styles.textinput} textContentType="username" />
            <TextInput style={styles.textinput} secureTextEntry textContentType="password" />
            <Button title="Dismiss Keyboard" onPress={() => Keyboard.dismiss()} />
        </View>
    )
}

const styles = StyleSheet.create({
    screen: {
        width: '100%',
        height: '100%',
        paddingVertical: '15%',
        backgroundColor: '#1e1e1e',
        alignItems: 'center',
    },
    textinput: {
        marginVertical: 10,
        padding: 10,
        width: '70%',
        height: 40,
        backgroundColor: '#ababab',
    },
})

export default App

【问题讨论】:

  • 您介意分享您遇到问题的整个组件的代码吗?
  • 嗨@James,我添加了一个精简版本,可以让我始终如一地重现问题。

标签: ios react-native keyboard expo autofill


【解决方案1】:

从 Expo SDK 34 升级到 Expo SDK 38 后,问题不再重现。

似乎至少在 Expo SDK 版本 34 中是一个问题。

【讨论】:

    猜你喜欢
    • 2023-03-03
    • 2016-08-09
    • 1970-01-01
    • 2021-01-01
    • 2019-02-07
    • 2017-11-24
    • 2017-07-22
    • 1970-01-01
    • 2021-12-18
    相关资源
    最近更新 更多