gorhom / react-native-bottom-sheet

A performant interactive bottom sheet with fully configurable options 🚀
https://gorhom.dev/react-native-bottom-sheet/
MIT License
7.08k stars 777 forks source link

[v4] | [v2] Initial Closed State with index prop not working properly... #1953

Open pdesign opened 1 month ago

pdesign commented 1 month ago

Bug

Environment info

Library Version
@gorhom/bottom-sheet 5.0.0-alpha.11
react-native ^0.74.5
react-native-reanimated ~3.10.1
react-native-gesture-handler ~2.16.1

Steps To Reproduce - Situation 1

  1. Create bottomsheet as documents show you to do.
  2. set only 1 snap point lets say 50%
  3. set index prop on the bottomsheet element to close bottomsheet initially

Describe what you expected to happen:

  1. bottomsheet comes closed initially...
  2. but you can not expand it

Steps To Reproduce - Situation 2

  1. Create bottomsheet as documents show you to do.
  2. set 2 snap point lets say 50% and 75%
  3. set index prop on the bottomsheet element to close bottomsheet initially

Describe what you expected to happen:

  1. bottomsheet comes closed initially...
  2. but when you first expand the bottomsheet it goes up and closes...
  3. on the other presses it works normal... just the first click it comes up and goes down...
github-actions[bot] commented 1 month ago

@pdesign: hello! :wave:

This issue is being automatically closed because it does not follow the issue template.

hariom-nft commented 1 month ago

Same issue here. This issue happens only on iOS for me. Android and Web works fine.

gorhom commented 1 month ago

@pdesign why not just submitting a expo snack to help me debug it faster :(

pdesign commented 1 month ago

@pdesign why not just submitting a expo snack to help me debug it faster :(

will add a code example here tomorrow

AradSharafi commented 1 month ago

Same issue here. I tried to submit a expo snack for you but unfortunately it gets stuck in connecting for me :(

Issue: BottomSheet won't open after setting the initial index on some Android devices

Description: When initializing the BottomSheet with index={-1}, the sheet no longer opens on certain Android devices. This behavior occurs inconsistently across different devices. For instance, it works fine on a Samsung Galaxy S23 but does not work on a Samsung Galaxy J5 Pro.

Dependencies: @gorhom/bottom-sheet: 5.0.0-alpha.11 expo: ~51.0.36 react: 18.2.0, react-native: ^0.75.4,

import MyBottomSheet, {BottomSheetView} from '@gorhom/bottom-sheet';

  const myRef = useRef<MyBottomSheet>(null);

  function open() {
    myRef.current?.collapse();
  }

  function close() {
    myRef.current?.close();
  }

  <View style={styles.screen}>
      <Button title='Open' onPress={open} />
      <Button title='Close' onPress={close} />

      <MyBottomSheet
        ref={myRef}
        index={-1}
        snapPoints={['50%', '90%']}
      >
        <BottomSheetView style={styles.contentContainer}>
          <Text vstyle={styles.text}>
            Awesome 🎉
          </Text>
        </BottomSheetView>
      </MyBottomSheet>
    </View>
AradSharafi commented 1 month ago

I updated it to 5.0.2, and the bug has been fixed

farellsmma commented 3 weeks ago

can confirm, updating the lib to v5.0.2 solved this issue