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

[v5] Bottom sheet is not longer opening #1751

Closed
Chasty opened this issue Feb 22, 2024 · 17 comments
Closed

[v5] Bottom sheet is not longer opening #1751

Chasty opened this issue Feb 22, 2024 · 17 comments
Assignees
Labels
bug Something isn't working invalid This doesn't seem right v5

Comments

@Chasty
Copy link

Chasty commented Feb 22, 2024

Bug

Environment info

Library Version
@gorhom/bottom-sheet 5.0.0-alpha.7
react-native 0.72.10
react-native-reanimated 3.3.0
react-native-gesture-handler 2.12.0

Steps To Reproduce

  1. just using this version "@gorhom/bottom-sheet": "4.4.7" it works perfectly.

Describe what you expected to happen:

I expect it to be opened.

Reproducible sample code

That's the code i have and whenever i want to open the bottom sheet it does not even open it.

import { View } from 'react-native'
import { BottomSheetBackdrop, BottomSheetModal } from '@gorhom/bottom-sheet'
import React, { RefObject, useCallback, useMemo } from 'react'
import CheatSheetContent from './CheatSheetContent'
import { styles } from './CheatSheet.styles'

type CheatSheetProps = {
  bottomSheetModalRef: RefObject<BottomSheetModal>
}

const CheatSheet = ({ bottomSheetModalRef }: CheatSheetProps) => {
  const renderBackdrop = useCallback(
    (props: React.ComponentProps<typeof BottomSheetBackdrop>) => (
      <BottomSheetBackdrop {...props} disappearsOnIndex={-1} appearsOnIndex={0} />
    ),
    []
  )

  const snapPoints = useMemo(() => ['85%'], [])

  return (
    <View>
      <BottomSheetModal
        ref={bottomSheetModalRef}
        index={0}
        snapPoints={snapPoints}
        backdropComponent={renderBackdrop}
        detached={false}
        handleStyle={styles.bottomSheetHandleStyle}
        handleIndicatorStyle={styles.bottomSheetIndicatorStyle}
        keyboardBlurBehavior="restore"
      >
        <CheatSheetContent />
      </BottomSheetModal>
    </View>
  )
}

And open it like this.

 const bottomSheetModalRef = useRef<BottomSheetModal>(null)

  const openBottomModal = useCallback(() => {
    bottomSheetModalRef.current?.present()
  }, [])
  const closeBottomModal = useCallback(() => {
    bottomSheetModalRef.current?.close()
  }, [bottomSheetModalRef])
  
  
<CheatSheet bottomSheetModalRef={bottomSheetModalRef} />
@Chasty Chasty added the bug Something isn't working label Feb 22, 2024
@Chasty
Copy link
Author

Chasty commented Feb 22, 2024

UPDATE: this is broken since this version 5.0.0-alpha.5, even the example from here does not open.

@malikzype
Copy link

+1..Works fine in alpha 6 but breaks in 7 and 8

@Chasty
Copy link
Author

Chasty commented Feb 28, 2024

In my case I need to remove the backdropComponent prop and it worked again, but now the bottom sheet opens sometimes. weird.

it is somehow related to this issue as well.

#1627

@TNAJanssen
Copy link

Same issue here

1 similar comment
@JosueCuberoSanchez
Copy link

Same issue here

@MoOx
Copy link

MoOx commented Apr 12, 2024

Getting the same problem with latest version 5.0.0-alpha.9.

@anton2mihail
Copy link

anton2mihail commented Apr 23, 2024

+ 1 here, on 5.0.0-alpha.9

There's also a weird Gesture related bug where even if enablePanDownToClose is false you're still able to close the bottom sheet using a 2 finger gesture across the top of the sheet.

Not sure if it's related but the bug is 100% consistent

@nileshzype
Copy link

+1
I am also face same issue with 5.0.0-alpha.9

With 5.0.0-alpha.4 its working fine.

Copy link

github-actions bot commented Jun 8, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Copy link

This issue was closed because it has been stalled for 5 days with no activity.

@joarkosberg
Copy link

+1
Experiencing same in 5.0.0-alpha.11, on scenarios without the BottomSheetView or the other wrappers. Like this example: https://ui.gorhom.dev/components/bottom-sheet/detach-modal

@Monir-Shembesh
Copy link

+1 Experiencing same in 5.0.0-alpha.11 as well.

@gorhom gorhom self-assigned this Oct 13, 2024
@gorhom gorhom added the v5 label Oct 13, 2024
@gorhom
Copy link
Owner

gorhom commented Oct 13, 2024

I have tested this on 5 alpha.11 , and it works

Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-10-13.at.14.20.48.mp4

@gorhom gorhom added invalid This doesn't seem right and removed no-issue-activity labels Oct 13, 2024
@Monir-Shembesh
Copy link

Monir-Shembesh commented Oct 13, 2024

I have tested this on 5 alpha.11 , and it works

Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-10-13.at.14.20.48.mp4

@gorhom can you please show us code example? Is this the Modal or just the bottom sheet? This is my setup:

Custom Bottom Sheet Modal Component

const BottomSheet = forwardRef<BottomSheetModal, BottomSheetModalProps>(
  ({ snapPoints, children, ...rest }, ref) => {
    const renderBackdrop = useCallback(
      (props: BottomSheetBackdropProps) => <Backdrop {...props} />,
      []
    );

    return (
      <BottomSheetModal
        ref={ref}
        snapPoints={snapPoints}
        enablePanDownToClose
        {...rest}
        backdropComponent={renderBackdrop}
      >
        {children}
      </BottomSheetModal>
    );
  }
);

Usage in code

  return (
    <>
      <BottomSheet ref={bottomSheetModalRef} snapPoints={['80%']}>
        <View style={styles.contentContainer}>
          <Text size="lg" type="primary">
            Present Modal
          </Text>
        </View>
      </BottomSheet>
    </>
  );

Like this it doesn't show up but if I use BottomSheetView it only displays the modal to the size of your child content.

Edit: I figured that the prop enableDynamicSizing must be set to false for it to show up @gorhom

@frozencap
Copy link

yes just upgraded to latest v5 and the bottom sheet doesn't open given some permutations of enableDynamicSizing,detached, backdropComponent.

@gorhom
Copy link
Owner

gorhom commented Oct 14, 2024

@Monir-Shembesh you need to replace the children of the bottom sheet from View to BottomSheetView, in order to get it working

@Monir-Shembesh
Copy link

Monir-Shembesh commented Oct 21, 2024

@Monir-Shembesh you need to replace the children of the bottom sheet from View to BottomSheetView, in order to get it working

It is working correctly if I use a normal View as a child with enableDynamicSizing prop set to false. I believe that BottomSheetView is mainly used for dynamic resizing correct? @gorhom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right v5
Projects
None yet
Development

No branches or pull requests