siemiatj / react-native-modal-dropdown

Fork of the original https://github.com/sohobloo/react-native-modal-dropdown
MIT License
119 stars 98 forks source link

Options disappear #81

Open ludgerey opened 2 months ago

ludgerey commented 2 months ago

Options disappear when clicked once.

Steps to reproduce:

-> First selected option disappears. Continues until there is only one option left.

It also has a weird spacing on the bottom.

Tested on android and ios.

import { SafeAreaView, StyleSheet } from 'react-native';
import ModalDropdown from "react-native-modal-dropdown";

export default function App() {
  return (
    <SafeAreaView style={styles.container}>
      <ModalDropdown options={["option 1", "option 2"]} />
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
});

Expo Snack: https://snack.expo.dev/@ley-syniotec/react-native-modal-dropdown-disappearing-options

screen

Dereisberg commented 2 months ago

I solve this problem by deleting this props line: initialScrollIndex={saveScrollPosition ? selectedIndex : -1} in function __renderDropdown(). It seems that it's a bug in component FlatList, I saw similar issues in react-native's repository: https://github.com/facebook/react-native/issues/44544.

image