react-native-sortables icon indicating copy to clipboard operation
react-native-sortables copied to clipboard

[Bug]: Focusing an input field near the bottom of a ScrollView in Android causes the view to scroll to the top unexpectedly.

Open devtm1123 opened this issue 1 year ago • 7 comments

Description

As the title says, input fields inside sortable gird near the bottom of a ScrollView in Android causes the view to scroll to the top unexpectedly.

  • A video showing how input fields work correctly in iOS

https://github.com/user-attachments/assets/d3006965-0706-4f6f-888d-f778e8782996

https://github.com/user-attachments/assets/3339f206-97d2-4c94-9f4c-77e5d0423afb

  • A video showing a bug that scrolls to the top in Android

I've tired setting in app.json

{
  "expo": {
    "android": {
      "softwareKeyboardLayoutMode": "pan"
    },
}

but it doesn't help... Please take a look at it. Thank you!

Steps to reproduce

import Sortable, { type SortableGridRenderItem } from "react-native-sortables";
import { useCallback } from "react";
import { TextInput, View } from "react-native";
import Animated, { useAnimatedRef } from "react-native-reanimated";

const scrollableRef = useAnimatedRef<Animated.ScrollView>();

const testData = new Array(50).fill(0).map((_, i) => ({
    id: i,
    name: `Exercise ${i}`,
  }));

 const renderExerciseItem = useCallback<
    SortableGridRenderItem<(typeof testData)[0]>
  >(
    ({ item }) => (
      <View className="bg-red-500 h-40">
        <TextInput placeholder={`TextInput#${item.id}`} keyboardType="numeric" />
      </View>
    ),
    [],
  );

<Animated.ScrollView
        contentContainerClassName="p-4 pb-32 gap-4"
        keyboardShouldPersistTaps="handled"
        ref={scrollableRef}
 >
 <Sortable.Grid
          columnGap={40}
          overDrag="vertical"
          scrollableRef={scrollableRef}
          data={testData}
          enableActiveItemSnap={false}
          columns={1}
          rowGap={10}
          renderItem={renderExerciseItem}
          activeItemScale={1.02}
        />
</Animated.ScrollView>

Code snippet, Snack or GitHub repository link

https://snack.expo.dev/@minth1123/sortable-grid-bug-in-android

React Native Sortables version

1.7.1

Reanimated version

3.18.0

React Native Gesture Handler version

2.26.0

React Native version

0.79.4

Platforms

Android

Architecture

Fabric (New Architecture)

Workflow

Expo Dev Client

Device

Android emulator

Acknowledgements

Yes

devtm1123 avatar Jul 25 '25 16:07 devtm1123

Thanks for reporting, I can confirm and it's impossible to use KeyboardAvoidingView behavior on Android, see #428

iCodePup avatar Jul 25 '25 16:07 iCodePup

Hey guys! I will look at the issue at the weekend and see if I can fix it somehow.

MatiPl01 avatar Jul 25 '25 16:07 MatiPl01

Hey guys! I will look at the issue at the weekend and see if I can fix it somehow.

Thank you! Looking forward to seeing it fixed :)

devtm1123 avatar Jul 25 '25 17:07 devtm1123

Hello @MatiPl01, thanks for handling this issue! I was wondering when the fixed version will be available for use?

devtm1123 avatar Jul 27 '25 23:07 devtm1123

Hey @devtm1123! I think that I should release the new version today or tomorrow if I find some bugs to fix.

MatiPl01 avatar Jul 28 '25 08:07 MatiPl01

I have just released v1.8.0, which should fix the issue. Please let me know if it works now once you get a chance to test it out.

MatiPl01 avatar Jul 29 '25 00:07 MatiPl01

I have just released v1.8.0, which should fix the issue. Please let me know if it works now once you get a chance to test it out.

Hey @MatiPl01, it's fixed now. Thanks for your work!

devtm1123 avatar Jul 29 '25 15:07 devtm1123