触摸/点击选择器
touch/ click in picker
我正在开发 android 应用程序。我想搜索并找到一个项目。我正在使用 react-native-modal-filter-picker 。它工作正常,但在显示结果时输入项目名称后,我无法 select 第一次单击/触摸的项目。
第一次触摸 - 停用键盘需要时间
只有在第二次触摸时,我才能 select 该项目。
我想 select 来自第一次点击的项目
我猜你要找的是 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>
);
}
}
我正在开发 android 应用程序。我想搜索并找到一个项目。我正在使用 react-native-modal-filter-picker 。它工作正常,但在显示结果时输入项目名称后,我无法 select 第一次单击/触摸的项目。
第一次触摸 - 停用键盘需要时间
只有在第二次触摸时,我才能 select 该项目。 我想 select 来自第一次点击的项目
我猜你要找的是 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>
);
}
}