触摸/单击选择器



我正在开发一个安卓应用程序。我想搜索并查找项目。我正在使用反应原生模态过滤器选择器。它工作正常,但是在显示结果时键入项目名称后,我无法从第一次单击/触摸中选择项目。

在第一次触摸中 - 停用键盘需要时间

只有在第二次触摸中,我才能选择该项目。 我想从第一次点击中选择项目

我想你要找的是keyboardShouldPersistTaps={'handled'}道具,这将考虑你第一次点击一个项目。如果单击特定项目,键盘将不会隐藏,如果要隐藏它,请考虑使用Keyboard.dismiss()

下面你会发现一个工作示例:

import React from 'react';
import {
View,
Keyboard,
} from 'react-native'
import ModalFilterPicker from 'react-native-modal-filter-picker'

export default class App extends React.Component {
render() {
const options = [
{
key: 'kenya',
label: 'Kenya',
},
{
key: 'uganda',
label: 'Uganda',
},
{
key: 'libya',
label: 'Libya',
},
{
key: 'morocco',
label: 'Morocco',
},
{
key: 'estonia',
label: 'Estonia',
},
];
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<ModalFilterPicker
options={options}
onSelect={option => {
console.log(option);
Keyboard.dismiss();
}}
onCancel={() => {}}
keyboardShouldPersistTaps={'handled'}
/>
</View>
);
}
}

最新更新