-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toggle not working in Android. #424
Comments
Also you can reproduce this bug with any onPress function |
I have the same issue, can anyone help? |
I have the same issue |
1 similar comment
I have the same issue |
@hasnaina-entertainer this should work. <>
<RNPickerSelect
disabled={!editable}
onValueChange={(v) => this.handleValueChange(v)}
value={selectedValue}
style={{ maxHeight: 0 }}
pickerProps={{ ref: this.pickerRef }}
ref={this.pickerRef}
onUpArrow={this.onArrowUp}
InputAccessoryView={this.InputAccessoryView}
onDownArrow={this.onDownArrow}
style={{
chevronUp: {
fontSize: 0,
color: 'white',
},
}}
items={values}>
<View style={{ height: 0 }}></View>
</RNPickerSelect>
<TouchableWithoutFeedback onPress={() => { this.pickerRef.current.focus(); }}>
{content}
</TouchableWithoutFeedback>
</> Short answer (Android only) <RNPickerSelect
{...otherProps}
pickerProps={{ ref: this.pickerRef }}
/> and then <TouchableWithoutFeedback onPress={this.pickerRef.current.focus}>
{content}
</TouchableWithoutFeedback> To make this work for Android & iOS you can do something like this class PickerSelect extends React.Component {
pickerRef = React.createRef()
openPicker() {
if (Platform.OS === 'android') {
this.pickerRef.current.focus()
} else {
this.pickerRef.current.togglePicker(true)
}
}
render() {
const { onValueChange, items, value } = this.props
return (
<RNPickerSelect
onValueChange={onValueChange}
items={items}
style={{ viewContainer: { height: 0 } }}
ref={Platform.OS === 'ios' ? this.pickerRef : null}
pickerProps={{ ref: Platform.OS === 'android' ? this.pickerRef : null }}
value={value}
/>
)
}
} and then const pickerRef = useRef();
<PickerSelect
ref={pickerRef}
items={values}
/>
<TouchableWithoutFeedback onPress={pickerRef.current.openPicker}>
{content}
</TouchableWithoutFeedback> |
I got message for |
Hello, this problem still presist on android devices, or is it only for me ? const handlePickerToggle = () => {
it works perfectly on ios, but on android it is working only if you press inside red square. any advice please? |
The solution above doesnt work for me, |
pickerRef.current.togglePicker(true); |
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
onPress
I am toggling withthis.pickerRef.current.togglePicker(false)
Expected behavior
Should open the picker
Screenshots
null
Additional details
Reproduction and/or code sample
The text was updated successfully, but these errors were encountered: