kirillzyusko / react-native-keyboard-controller

Keyboard manager which works in identical way on both iOS and Android
https://kirillzyusko.github.io/react-native-keyboard-controller/
MIT License
1.39k stars 55 forks source link

Limited Items Displayed in KeyboardAwareScrollView with FlashList #497

Open AradSharafi opened 5 days ago

AradSharafi commented 5 days ago

Describe the bug When using the KeyboardAwareScrollView component in conjunction with FlashList, only a subset of the total items is displayed. For instance, if there are 100 items, only the first 30 items are rendered instead of all 100. By the way I pass KeyboardAwareScrollView to renderScrollComponent prop.

Code snippet

import React from 'react';
import { View, Text } from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
import { FlashList } from '@shopify/flash-list';

const items = Array.from({ length: 100 }, (_, index) => `Item ${index + 1}`);

const MyComponent = () => {
  return (
    <View>
      <FlashList
        data={items}
        renderItem={({ item }) => (
          <View style={{ height: 50, borderBottomWidth: 1, borderBottomColor: '#ccc' }}>
            <Text>{item}</Text>
          </View>
        )}
        estimatedItemSize={50}
         renderScrollComponent={(props) => (
          <KeyboardAwareScrollView {...props} />
        )}
      />
    </View>
  );
};

export default MyComponent;

Expected behavior All 100 items should be displayed within the FlashList when scrolling through the list. The KeyboardAwareScrollView should handle keyboard events appropriately without interfering with the rendering of all items in the FlashList.

Screenshots https://github.com/kirillzyusko/react-native-keyboard-controller/assets/88803340/933812c6-9a04-4a73-8e79-869af83ce74c

Smartphone (please complete the following information):

kirillzyusko commented 5 days ago

@AradSharafi why do you use KeyboardAwareScrollView from react-native-keyboard-aware-scroll-view?

This code snippet works fine in my example app:

import React from 'react';
import { View, Text } from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller';
import { FlashList } from '@shopify/flash-list';

const items = Array.from({ length: 100 }, (_, index) => `Item ${index + 1}`);

const MyComponent = () => {
  return (
    <View style={{ flex: 1 }}>
      <FlashList
        data={items}
        renderItem={({ item }) => (
          <View style={{ height: 50, borderBottomWidth: 1, borderBottomColor: '#ccc' }}>
            <Text>{item}</Text>
          </View>
        )}
        estimatedItemSize={50}
         renderScrollComponent={(props) => (
          <KeyboardAwareScrollView {...props} />
        )}
      />
    </View>
  );
};

export default MyComponent;
AradSharafi commented 5 days ago

Oh Sorry my bad. You're right about react-native-keyboard-aware-scroll-view.

but it remains the bug for me.

kirillzyusko commented 5 days ago

@AradSharafi I'm using the 1.12.5 version - can you try this one? If the bug remains, then please, create a reproduction example because I cannot reproduce this problem in my example app

AradSharafi commented 1 day ago

@kirillzyusko I tried the 1.12.5 version and a new error has arisen.

I just updated and didn't change anything.

description
kirillzyusko commented 1 day ago

@AradSharafi I can not help here as I haven't seen a similar error in my project 🤷‍♂️ Please, create a reproduction example 🙏

Or you can try 1.11.6 version - this version had a fix for missing onScroll handler.