-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
IOS TouchableHighlight need tap twice to trigger onPress function #12784
Comments
Are you using a ScrollView? By default when an input is focused the tap will close the keyboard but not trigger any other touch events. You can change that behavior using http://facebook.github.io/react-native/docs/scrollview.html#keyboardshouldpersisttaps |
Dear @janicduplessis , the CommentInput component did not included in a ScrollView, at first , the Button(TouchableHightlight) can receive the onPress method, but after several quick open the CommentInput component use keyboard to input some text and at the same time press the background to close the CommentInput., next Time the Button component won't accept the onPress method at the first tap, and the second time the Button works. I don't know why. I also search a lot of issues to find the solution. but I did get the answer |
I also have this problem sometimes on 0.43 |
@RichardLindhout did you find the solution? |
Probably same problem as #12976 is. |
@avivaWang How hard is it to reproduce this problem? |
I think it has something to do with a busy JavaScript thread. |
Yeah, probably. I hope fixing #12976 also will fix this problem. |
I have this problem on 0.41.0 with a ScrollView which contains TouchableHighlights. In my case |
@vinayan3, Since there are a million threads already about |
... Speaking about scrollviews, |
@avivaWang While I didn't find a solution, there is a workaround for the case when your keyboard has been dismissed but the focus of the TextInput is still preventing your buttons from being clicked. If you use a keyboard listener from the Keyboard API, you can blur the input when the keyboard is dismissed: componentDidMount(){
this.keyboardDidHideListener = Keyboard.addListener("keyboardDidHide", () => {
this.refs.input.blur();
});
}
componentWillUnmount(){
this.keyboardDidHideListener.remove();
} |
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally! If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution. |
I think it is related to this issues #15606 |
I use a FlatList instead a ScrollView. |
The original issue of needing two taps to activate onPress is still exits. I don't know why it's been closed. The original code still reproduces the issue in latest releases. |
I develop android app |
FlatList does not have property |
@vuphuctho they do, flatlist inherate scrollview props dude.. |
keyboardShouldPersistTaps doesn't work on iOS(react-native 0.51.0). |
@hnanh is right, keyboardShouldPersistTaps doesn't work on RN 0.51+ |
+1 on this issue. Still need to double tap before the item receives the tap. |
Did anyone solve this problem? I am using RN 0.52.2 |
Solved it by making sure that all parent ScrollView Props keyboardShouldPersistTaps is set to "handled". |
what fixed it for me is to make sure that all nested scrollviews have this property set: keyboardShouldPersistTaps='always'. This won't work because the parent ScrollView does not have this property set. |
I see, have you tried using a different Touchable component? Like TouchableOpacity |
yes @dsc-bon. I was working with TouchableOpacity and it worked just giving all ScrollViews the same keyboardShouldPersistTaps='always' prop. Thanks |
I was facing the same issue with FlatList (RN -> 0.52.0). But resolved when used |
Is there any solution not involving the addition of a scrollview (or any other component)? |
Facing the same issue here. A simple Input and a TouchableOpacity. Adding a ScrollView around with the |
@msevestre make sure that ALL child container were placed inside the ScrollView |
What do you mean with child container? ;+) I have a modal view with one input and two buttons. Cheers |
@msevestre |
This issue goes away when switching to |
In my Project, I have a TextInput and a TouchableHighlight , the code is below:
and in another file:
when I use the keyboard to input some words and press the TouchableWithoutFeedback at the same times, several times , the TouchableWithoutFeedback need to tap twice to trigger the onPress function. how to solve this bug?
The text was updated successfully, but these errors were encountered: