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

Item's onPress does not work when inside ScrollView #5

Closed
joonhocho opened this issue May 17, 2016 · 10 comments

Comments

@joonhocho
Copy link

commented May 17, 2016

As title says, selecting item is not working when nested inside a ScrollView.

@joonhocho

This comment has been minimized.

Copy link
Author

commented May 17, 2016

@mrlaessig

This comment has been minimized.

Copy link
Owner

commented May 26, 2016

Do you have still problems with RN v0.26.2?

@saemie

This comment has been minimized.

Copy link

commented Jun 1, 2016

I am getting the same problem with RN v0.26.2
onPress does not work for items passed to the renderItem property.

I'm testing this with the example app. Any idea what the problem may be?

@mrlaessig

This comment has been minimized.

Copy link
Owner

commented Jun 1, 2016

@saemie Do you use the same code from the example? Do you test on the device or emulator?

@ajoshdee

This comment has been minimized.

Copy link

commented Jul 11, 2016

Hi, I tested it using your example but I'm having a hard time selecting from the list returned by autocomplete. my autocomplete component is inside a scroll view

@bbalu

This comment has been minimized.

Copy link

commented Jul 18, 2016

After removing this following line, TouchOpactity onPress function is being called.
<TextInput
...
onEndEditing={e =>
this._showResults(false) || (onEndEditing && onEndEditing(e))
}
...

@ltquang

This comment has been minimized.

Copy link

commented Aug 5, 2016

Hello,
I have 1 solution for you
please add keyboardShouldPersistTaps={true} in your scrollview

ScrollView keyboardShouldPersistTaps={true}
.
   Autocomplete
                    ....
                    renderItem={data => (
                      <TouchableOpacity onPress={() => this.props.onSelectedProvinceChange(data)}>
                        <Text style={{color: Commons.Colors.gray_dark, fontFamily: Commons.Fonts.regular, fontSize: Commons.Fonts.p}}>{data}</Text>
                      </TouchableOpacity>
                    )}
                  />
/ScrollView

*It's work for me :) Hope to help you

@mrlaessig

This comment has been minimized.

Copy link
Owner

commented Aug 7, 2016

Thx @ltquang your suggestion to add the keyboardShouldPersistTaps={true} prop to the ScrollView seems to fix the issue.

@panuhorsmalahti

This comment has been minimized.

Copy link

commented Mar 20, 2018

While adding keyboardShouldPersistTaps to true (well, "always" these days) fixes this issue, I need to have keyboardShouldPersistTaps "never" to close the keyboard after clicking outside inputs. Therefore this solution is not suitable for me.

@armadillojim

This comment has been minimized.

Copy link

commented Jun 19, 2018

@panuhorsmalahti, have you tried setting keyboardShouldPersistTaps to handled? Dunno if that'll fix your issue, but it's worth a try. FWIW, I have a ScrollView with multiple autocomplete fields, and clicking outside them closes the keyboard for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.