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

Animated component issue: touchables and TextInputs inside the Animated.ScrollView are not responsive #6070

Open
NodoPopkhadze opened this issue Jun 3, 2024 · 6 comments
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snippet of code, snack or repo is provided

Comments

@NodoPopkhadze
Copy link

NodoPopkhadze commented Jun 3, 2024

Description

I'm encountering an issue with the Animated component in React Native. When using Animated.ScrollView alongside Animated.View, the touchable components and TextInput inside the Animated.ScrollView are not responsive after scrolling. This issue occurs only on the fabric architecture and only on a real device.

The provided demo is quite primitive and has the purpose of demonstrating the bug.

This bug was originally found in the react-native-keyboard-controller library, which uses a similar solution for keyboard panning. For a more detailed example of this bug, you can visit the react-native-keyboard-controller repository and check the AwareScrollViewStickyFooter example.

Also note that if you change React Native touchables (e.g., TouchableOpacity, TouchableHighlight) to "react-native-gesture-handler" touchable components, the problem is solved. Additionally, react-native-gesture-handler TextInput becomes responsive in Animated.ScrollView. However, when a TextInput component from react-native-gesture-handler is used, touching it to input text prevents scrolling of the screen. So bug remains problematic.
https://github.com/software-mansion/react-native-reanimated/assets/47716245/4b27cc16-c47d-4f12-9381-1f623eb2e11f

Steps to reproduce

  1. Create a new React Native project
  2. Import Animated from 'react-native'
  3. Add an Animated.ScrollView with some touchable content and TextInput components
  4. Add an Animated.View alongside the Animated.ScrollView
  5. Run the application on a real device using the fabric architecture
  6. Scroll the Animated.ScrollView a little bit
  7. Try to click any TextInput or button

Snack or a link to a repository

https://github.com/NodoPopkhadze/ReanimatedBugExample

Reanimated version

3.9.0

React Native version

0.74.1

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Fabric (New Architecture)

Build type

Debug app & production bundle

Device

Real device

Device model

Samsung Galaxy S21

Acknowledgements

Yes

@github-actions github-actions bot added Platform: Android This issue is specific to Android Repro provided A reproduction with a snippet of code, snack or repo is provided labels Jun 3, 2024
@NodoPopkhadze NodoPopkhadze changed the title Animated component issue: Animated.ScrollView touchables and TextInputs not responsive. Animated component issue: touchables and TextInputs inside the Animated.ScrollView are not responsive. Jun 3, 2024
@NodoPopkhadze NodoPopkhadze changed the title Animated component issue: touchables and TextInputs inside the Animated.ScrollView are not responsive. Animated component issue: touchables and TextInputs inside the Animated.ScrollView are not responsive Jun 3, 2024
@datachanturia
Copy link

Having the same issue for 3.10.1 version.

@szydlovsky
Copy link
Contributor

Hey @NodoPopkhadze @datachanturia, the issue seems to be fixed in the newest (3.12) Reanimated version. Please check it out and let me know if it helped!

@NodoPopkhadze
Copy link
Author

NodoPopkhadze commented Jun 7, 2024

Hi @szydlovsky, unfortunately, the issue persists. The behaviour is still the same across all touchable or TextInput components. The bug shows up after scrolling slightly and then attempting to interact with the pressable components(TouchableOpacity, TextInputs and etc).

It’s important to note that this issue only occurs on real Android devices and only on new/fabric architecture. it works fine on an emulator. Additionally, I have updated the Reanimated library to the latest version in the provided repository, but the problem remains unresolved.

@jakecurreri
Copy link

jakecurreri commented Jun 28, 2024

+1. Have this issue for 3.12.1. Any Pressable component inside an Animated.ScrollView requires several taps to trigger a response, or it is not responsive at all. Testing on both an emulator and physical device (iOS).

@szydlovsky
Copy link
Contributor

szydlovsky commented Jul 1, 2024

@jakecurreri would you be able to provide a reproduction (or a code snippet) for you iOS issue?

@jakecurreri
Copy link

jakecurreri commented Jul 1, 2024

@szydlovsky sure. Here is an example of one Pressable inside the Animated.ScrollView. I have more Pressable components inside the view, and all have the same issue.

The ScrollView component:

...
const scrollY = useSharedValue(0);
const scrollHandler = useAnimatedScrollHandler(event => {
   scrollY.value = event.contentOffset.y;
});
...
return (
   <>
      <AnimatedBlock scrollY={scrollY} />
      <Animated.ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={styles.screen}
        onScroll={scrollHandler}
        scrollEventThrottle={16}
      >
          <Pressable
            onPress={() => navigation.goBack()}
            style={styles.back}
            hitSlop={16}>
            <ChevronLeftIcon color="#FFFFFF" size={22} />
          </Pressable>
         {...content}
      </Animated.ScrollView>
   </>
)

And the AnimatedBlock:

...
const animatedStyle = useAnimatedStyle(() => {
   const translateYValue = scrollY.value > scrollThreshold ? 0 : -50;
   translateY.value = withTiming(translateYValue);
   return {
      transform: [{translateY: translateY.value}],
   };
 });
 ...
 return (
     <Animated.View style={animatedStyle}>
     {...content}
     </Animated.View>
 )

I've also tried upgrading to the latest release candidate and downgrading all the way to 3.10. No luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snippet of code, snack or repo is provided
Projects
None yet
Development

No branches or pull requests

4 participants