-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
FlatList item onPress not work the first time after refreshed #20011
Comments
Fascinating. Does it work without a refresh control? What about a touchablewithoutfeedback instead of a touchablehighlight? |
|
Update that Android doesn't has this bug. |
Does this repro with v0.56.0? |
Yes it still does. // Updated first post with latest info from |
Same issue! |
This reproes with ScrollView, not just FlatList.
Someone will need to dig into the ScrollView implementation and see if something funky is happening with the refresh control. It could also be somewhere in the ScrollableMixin or something like that. This is the example I used:
|
Are there any workarounds for this? Invoke a fake scroll or touch event? Any more hints for how to go about fixing? |
setState does not re-render nor update FlatList on iOS event with the extraData workaround any solution? |
I used a setTimeout to solve the issue |
Thanks @rayhk6, this works fine for me ! |
it's not perfect, it's will show after 200ms, not immediately |
add "title" in RefreshControl, can be work in v0.56 |
I recognized that not only |
onPress is normal,code is normal ,but refresh is not work
|
Same issue. Every touchable item on screen is not clickable after refresh |
for me too, tested on 0.57.7 |
Thanks everyone! While we agree that this repros, it would be great if someone wanted to investigate into the root cause. "Me too"s don't really help us solve this. 😕 |
Same issue here!! I stuck here for two days already! react-native: 0.55.4 1: try to add title for RefreshControl still cannot work. @binlaniua Here is My Code: `
` |
Same issue. Also setTimeout doesn't work for me because of the breaking animation. Somebody has a better solution? |
The following are the details I found by debugging, may be some one more familiar with reactnative event plugin could take it further.
The issue happens because
Nesting of components is like this There are lots of events fired in following order
The partial flow is when we pull to refresh,
Hope someone familiar with ScrollView responder system and react event system can take it further. EDIT 1: In ScrollView setting EDIT 2: Tagging people who might know about this, @shergin |
me too ,0.61.4 |
@ravirajn22 , thanks! Passing |
This worked for me properly on a SectionList Thanks a lot! |
This worked for me Thanks |
disableScrollViewPanResponder = {true} fix the bug |
Does anybody know what the consequences of using On another note - I figured out that this bug doesn't occur when you swipe down and release quickly. It only happens if you swipe down and still hold your finger down after the list has refreshed. Hopefully this helps. |
same bug here with the simple FlatList |
I've been stuck with a similar issue I don't know if its related or not. I'm developing for android only using a ScrollView and on a real device I can click buttons, they respond to being touched with the downstate etc but onPress doesn't trigger. disableScrollViewPanResponder = {true} did not help in this case |
I needed to increase the timeout to 400, but it doesn't appear to be working so far... |
Still facing this issue on Android. Any solution for this? Even adding a setTimeout doesn't work for me |
Hi all, I found the bug and the actual problem was with updating the redux state (there is some kind of delay here). If you're updating the state on press, please comment that code and check if it works for you. In my case I was updating the state on press and opening an animated view... This is a weird issue. I should find a way now to pass the updated state before displaying the animated view |
Summary: According to #20011, the first onPress will not work after pull to refresh. Dive into the code, found out that is because the state `isTouching` in `Libraries/Components/ScrollResponder.js` is not updated after the pull to refresh. Update the `isTouching` state in `scrollResponderHandleResponderRelease` to fix this. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [iOS] [Fixed] - First press not working after pull to refresh Pull Request resolved: #30291 Test Plan: ### Before - The first onPress fail ![ezgif-4-c6aa5383e898](https://user-images.githubusercontent.com/48589760/97789482-cd4c4100-1bfb-11eb-8a6b-649e8a966b99.gif) ### After - The first onPress success ![ezgif-4-195f9f6c302e](https://user-images.githubusercontent.com/48589760/97789488-da693000-1bfb-11eb-9a87-f005e61b8ad0.gif) Eli: I tested this myself internally using this code sample: ``` 'use strict'; import PlaygroundRoute from 'PlaygroundRoute'; import type {SurfaceProps} from 'Surface'; import TetraText from 'TetraText'; import TetraView from 'TetraView'; import {TouchableOpacity, Text, View, ScrollView, RefreshControl, StyleSheet} from 'react-native'; import * as React from 'react'; type Props = SurfaceProps<PlaygroundRoute>; class App extends React.Component<{}> { constructor() { super(); this.state = {refreshing: true, items: []}; } componentDidMount() { this.refresh(); } refresh = () => { this.setState({ refreshing: true, items: [], }); setTimeout( () => this.setState({ refreshing: false, items: [0, 1, 2, 3, 4, 5], }), 1500, ); }; renderItem = ({item}) => { return ( <TouchableOpacity onPress={() => alert('pressed!')} key={`${item}`}> <Text style={{width: '100%', height: 48, backgroundColor: 'white'}}> {item} </Text> <View style={{width: '100%', height: 1, backgroundColor: 'gray'}} /> </TouchableOpacity> ); }; render() { return ( <View style={{flex: 1, padding: 48}}> <ScrollView style={{ flex: 1, backgroundColor: '#aaa', borderColor: 'gray', borderWidth: 1, }} keyExtractor={item => `${item}`} refreshControl={ <RefreshControl refreshing={this.state.refreshing} onRefresh={this.refresh} /> }> {this.state.items.map(item => this.renderItem({item}))} </ScrollView> </View> ); } } export default function Playground(props: Props): React.Node { return ( <App /> ); } const styles = StyleSheet.create({ container: { padding: 10, paddingTop: 30, }, }); ``` {F351458967} Reviewed By: appden Differential Revision: D25574927 Pulled By: TheSavior fbshipit-source-id: 7abf8a2f947d94150419e51d46a19e792441c981
The fix for this has been landed in #30291 As 0.64 has already been cut and is close to release I don't expect this to be included there. I expect this to be part of 0.65. |
Infact you are the real Savior! After 2 years 😁 |
It wasn't me at all, it was all @yum650350. This was their first contribution to React Native! |
@ravirajn22 Thank you! |
if onPress is not workingin the flatlist's renderItem method try using onTouchStart method of the components if they have in the flatList's renderItem method. |
try import { TouchableOpacity } from 'react-native-gesture-handler'; |
@Rahulnagarwal perfect! |
I don't understand why this hasn't been fixed yet. It only happens on Android I'm really struggling with that. I don't use Here my setup
Here the process
I tried Please help !!!! |
Not working when using a custom refreshControl |
it worked here s2 |
Thank you, it works on RN 0.64 |
Hey guys, I managed to solve my problem by following this question https://stackoverflow.com/questions/68502633/react-native-why-is-my-flatlist-not-displaying Props that I added to my flatList to work.
Hope this helps you too <3 |
Hey guys, I managed to solve my problem by following this question https://stackoverflow.com/questions/68502633/react-native-why-is-my-flatlist-not-displaying Props that I added to my flatList to work.
Hope this helps you too <3 |
Environment
Description
FlatList
has item withTouchableHighlight
, and aRefreshControl
attached.onPress
method ofTouchableHighlight
is not working the first time afteronRefresh
called.If I scroll
FlatList
a bit after refreshed, then itemonPress
works fine.// UPDATE: Android does not have this bug.
Reproducible Demo
Fresh project created by
react-native init
The text was updated successfully, but these errors were encountered: