Skip to content
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

Android: Picker not responding to touch correctly inside Touchable #354

Closed
deansimcox opened this issue Aug 26, 2020 · 18 comments
Closed

Android: Picker not responding to touch correctly inside Touchable #354

deansimcox opened this issue Aug 26, 2020 · 18 comments
Labels
bug Something isn't working

Comments

@deansimcox
Copy link
Contributor

Describe the bug

Under certain conditions on physical Android devices, tapping on <RNPickerSelect /> does not always trigger the dialog menu to show.
The root cause of this issue appears to be rendering a <Picker /> inside of a <TouchableOpacity />
More info: facebook/react-native#25203

To Reproduce

Steps to reproduce the behavior:

  1. Render a <RNPickerSelect /> with children
  2. 'react-native-picker-select' then renders using renderAndroidHeadless()
  3. On a physical android device, tap the rendered <RNPickerSelect />
  4. Observe if this opens up the picker
  5. Repeat steps 3 and 4, 20 times
  6. Observe that the picker has not opened 20 times

Expected behavior

After tapping a <RNPickerSelect /> 20 times, the picker should have also opened 20 times.

Screenshots

"n/a".

Additional details

  • Device: OnePlus 5T
  • OS: Android 9
  • react-native-picker-select version: 6.6.0
  • react-native version: 0.62.2
  • expo sdk version: n/a

Reproduction and/or code sample

https://snack.expo.io/@deansimcox/brave-cashew
Note: Please make sure you run this expo snack on an actual android device, the issue is not present when using the Android view on expo.

@naveen1601
Copy link

naveen1601 commented Sep 1, 2020

I am facing the same issue. Is there any solution of this? It is becoming critical for me, lots of users are complaining about this.

@deansimcox
Copy link
Contributor Author

Making this change (331824c) should fix it, however this would also remove the touchable opacity feedback, so that might not be desirable.

@naveen1601
Copy link

Thanks @deansimcox. It worked 👍

@lfkwtz
Copy link
Collaborator

lfkwtz commented Sep 3, 2020

@deansimcox any chance this is related to #237 ?

@MrtYlnzz
Copy link

MrtYlnzz commented Sep 7, 2020

This is a similar issue with me and 331824c solves it. Any chance this will be solved in upcoming versions?

@neiker
Copy link

neiker commented Sep 11, 2020

Should be nice to release a new version with this fix

@lfkwtz lfkwtz added the bug Something isn't working label Oct 14, 2020
@lfkwtz
Copy link
Collaborator

lfkwtz commented Oct 14, 2020

don't want to make a breaking change quite yet, so fixed with a conditional flag in 8.0.2

worth investigating how the new Pressable component reacts to this vs the bug found with TouchableOpacity

@oli-laban
Copy link

@lfkwtz Pressable unfortunately seems to have the same issue.

Showing feedback on press is quite important and we can't even implement our own animation as <Picker> doesn't provide a callback on open.

@johnlund
Copy link

johnlund commented Feb 26, 2021

fixAndroidTouchableBug={true} seems to solve this for me.

@thethirdship
Copy link

On android it would intermittently not respond to the user's touch. Originally, I wasn't sure if it was my layout, or I was doing something else to lock the app.

After setting this prop on version 8.0.3, fixAndroidTouchableBug={true}, it is firing consistently. Thank you!!!

For me if I had to choose whether to have feedback or consistently have the dialog come out on press, I choose the dialog.

Is the breaking change only for older versions of the package, older androids, or people expecting a feedback???

@AVancans
Copy link

Although fixAndroidTouchableBug fixes the click issue, it disables all onOpen, onClose callbacks. :(

@socheat-leang
Copy link

@AVancans Yes. I just faced this issue the same you.

@MHase
Copy link

MHase commented Sep 22, 2021

after all this time fixAndroidTouchableBug fixed this bug for me also 😃

@mwegener-com
Copy link

I have the same problem as described above but fixAndroidTouchableBug doesn't work for me.
Do you have any Idea?

My Component

	<View style={styles.card}>
			<View style={styles.container}>
				<View style={styles.leftView}>
					<MyIcon
						customIcon={{ name: iconName, bib: iconBib }}
						size={25}
						color={value ? colors.primary : colors.defaultGrey}
					/>
				</View>
				<View style={layoutStyles.verticalLine}></View>
				<View style={styles.rightView}>
					<RNPickerSelect
						onValueChange={(itemValue) => setValue(itemValue)}
						items={data}
						placeholder={{ label: placeholder, value: null }}
						onOpen={() => {
							onPress();
						}}
						fixAndroidTouchableBug={true}
						useNativeAndroidPickerStyle={false}
						style={{
							placeholder: styles.placeholderStyle,
							inputAndroid: styles.input,
							inputAndroidContainer: styles.inputContainer,
							inputIOS: styles.input,
							inputIOSContainer: styles.inputContainer,
						}}
					/>
				</View>
			</View>
		</View>

My Styles

card: {
		...inputStyles.inputContainer,
		flexDirection: 'column',
		minHeight: dimensions.textfieldHeight,
		height: undefined,
		maxHeight: dimensions.textfieldHeight * 5,
	},
	container: {
		height: dimensions.textfieldHeight,
		alignItems: 'center',
		flexDirection: 'row',
	},
	leftView: {
		...inputStyles.leftView,
	},
	rightView: {
		...inputStyles.rightView,
		flexDirection: 'row',
		justifyContent: 'flex-start',
	},
	placeholderStyle: {
		...inputStyles.normalLabel,
	},
	inputView: {
		width: '100%',
		justifyContent: 'center',
	},
	inputContainer: {
		width: '100%',
		height: '100%',
		justifyContent: 'center',
	},
	input: {
		...textStyles.bodyText,
	},

Bildschirmfoto 2021-11-07 um 03 38 24

@eluzgin
Copy link

eluzgin commented Mar 27, 2022

I confirm that adding these 2 lines fixed this issue for me:
fixAndroidTouchableBug={true}
useNativeAndroidPickerStyle={false}

@Carles11
Copy link

fixAndroidTouchableBug={true}
useNativeAndroidPickerStyle={false}

That worked like a charm for me too. Thanks!

@MrShakes
Copy link

MrShakes commented Oct 5, 2023

Spent a few hours trying to fix this, please the solution here should be placed in a troubleshooting section on the home page

@lfkwtz
Copy link
Collaborator

lfkwtz commented Oct 17, 2023

feel free to open a pr for that @MrShakes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests