lawnstarter / react-native-picker-select

🔽 A Picker component for React Native which emulates the native <select> interfaces for iOS and Android
https://npmjs.com/package/react-native-picker-select
MIT License
1.74k stars 499 forks source link

[Android] - Icon not pressable #237

Open dooleyb1 opened 4 years ago

dooleyb1 commented 4 years ago

Describe the bug
When using a custom Icon component within the RNPickerSelect component I am unable to press the icon and open the Picker on Android. It works perfectly as expected on iOS.

To Reproduce
See the code below.

Expected behavior
Expect to click on the Icon to the right and for the Picker modal to open up. This is not the case on Android, however it works perfectly on iOS.

Screenshots
iOS:

Screenshot 2019-10-09 at 13 24 55

Android:

Screenshot 2019-10-09 at 13 25 00

Additional details

Reproduction and/or code sample

https://snack.expo.io/Hkrt-UidS

<RNPickerSelect
    onValueChange={(value, index) => this.handleSelection(value, index)}
    value={this.state.college}
    placeholder={{
        label: 'Select your college/university',
        value: null,
    }}
    style={{
        ...pickerSelectStyles,
        iconContainer: {
            top: 10,
            paddingRight: scaleFontSize(33)
        },
    }}
    items={colleges}
    Icon={() => {
        return <Icon
            name="ellipsis-h"
            type="font-awesome"
            underlayColor="transparent"
            iconStyle={styles.editIcon}
        />
    }}
/>
lfkwtz commented 4 years ago

thanks for the detailed bug report - will check it out

dooleyb1 commented 4 years ago

Thanks man. Is it possible to open the modal dialog via the onPress() method of the Icon?

lfkwtz commented 4 years ago

doubtful - the problem is on android there isn't a way to programmatically trigger the dialog #22

lfkwtz commented 4 years ago

fwiw - i just checked the sample expo - https://snack.expo.io/@lfkwtz/react-native-picker-select

doesn't seem to be an issue with the icons there

maybe that will help you debug this

dooleyb1 commented 4 years ago

So, I've actually managed to resolve this issue. Turned out the missing prop that was preventing the Icon from being clickable was useNativeAndroidPickerStyle={false}. Once this was added everything worked perfectly as expected. Thanks for your help @lfkwtz 👍

ryanbabbly commented 4 years ago

I'm having this exact issue with my project. The box is touchable but the icon is not.

I'm using: Device: [Pixel 2] OS: [Android 10.0] react-native-picker-select version: [^7.0.0] react-native version: [0.63.2] react version: [16.13.1]

This is my picker:

<Picker
    onValueChange={onValueChange}
    useNativeAndroidPickerStyle={false}
    placeholder={{}}
    items={items}
    Icon={() => <Icon name="keyboard-arrow-down" size={32} color={theme.colors.primary} />}
    {...props}
/>

The picker worked fine before in an expo managed workflow, but I ejected just now and suddenly the icon doesn't open the picker no matter what I try.

bittu1028 commented 4 years ago

same issue icon not being pressable on android.

GUITARPLRC commented 4 years ago

Also having the same issue. Please reopen 🙏

NonkelDaniel commented 4 years ago

I'm also having this exact problem, however it only happens on a physical device (samsung galaxy tab a (10 inch)). It does work on the emulator.

btuck044 commented 4 years ago

Same issue here as with NonkelDaniel

leonimurilo commented 4 years ago

Same issue :/

<RNPickerSelect
  onValueChange={value => {
    dispatch(shoppingListDuck.creators.setCurrentList(value));
  }}
  useNativeAndroidPickerStyle={false}
  style={pickerSelectStyles}
  placeholder={{}}
  value={currentList ? currentList._id : null}
  items={lists.map(list => ({ label: list.name, value: list._id }))}
  Icon={() => {
    return <Icon name="chevron-down-outline" size={24} color="black" />;
  }}
/>

const pickerSelectStyles = StyleSheet.create({
  inputIOS: {
    fontSize: 16,
    paddingVertical: 12,
    paddingHorizontal: 10,
    borderWidth: 1,
    borderColor: 'gray',
    borderRadius: 4,
    color: 'black',
    paddingRight: 30, // to ensure the text is never behind the icon
  },
  inputAndroid: {
    fontSize: 24,
    fontWeight: "bold",
    // backgroundColor: "#eee",
    paddingHorizontal: 10,
    paddingVertical: 8,
    borderWidth: 0.5,
    borderColor: 'transparent',
    borderRadius: 8,
    color: 'black',
    // paddingRight: 30, // to ensure the text is never behind the icon
  },
  iconContainer: {
    top: 10,
    right: 12,
  },
});
notjulian commented 3 years ago

fwiw - i just checked the sample expo - https://snack.expo.io/@lfkwtz/react-native-picker-select

doesn't seem to be an issue with the icons there

maybe that will help you debug this

Hi If I click on the picker with custom icon (custom icon using your own css) doesn't works for me

thanks

shubhankar30 commented 3 years ago

+1

leonimurilo commented 3 years ago

+1

andreibursuc97 commented 3 years ago

seems that setting the flag _fixAndroidTouchableBug_ to _true_ fixes the problem

Loovery commented 3 years ago

+

erikaperugachi commented 3 years ago

Exactly! the solution is: fixAndroidTouchableBug={true}

Should be upload version: 8.0.2

taymeric commented 3 years ago

Same issue here with: physical device running Android 11 react-native-picker-select 8.0.2 react 16.13.1 react-native 0.63.2

<RNPickerSelect> with the following props as suggested in this discussion doesn't solve the issue:

useNativeAndroidPickerStyle={false}
fixAndroidTouchableBug={true}
gazedash commented 3 years ago

Bump

ibtisamarif831 commented 3 years ago

Same issue here, Icon works fine when wrapped around View but has issues when wrapped around touchableOpacity.

fixAndroidTouchableBug={true} Even this does not help. Not all devices tho, tested on huawei p20 lite and galaxy s6.

denisvely commented 2 years ago

Any updates on this? it isn`t working with useNativeAndroidPickerStyle={false} fixAndroidTouchableBug={true}.

jasperhuangg commented 1 year ago

Hi! Still experiencing this issue as well on Android. Also passing the following props:

useNativeAndroidPickerStyle={false}
fixAndroidTouchableBug={true}

For me, only the left third of the picker responds to touch.

TolaAbiodun commented 1 year ago

Same issue here with: physical device running Android 8 react-native-picker-select 8.0.4 react 17.0.2 react-native 0.68.2

useNativeAndroidPickerStyle={false} fixAndroidTouchableBug={true}

The above suggestion works