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

[Bug]: Sheet not showing after upgrading react native from 0.75.4 -> 0.76.0 #2015

Open
LA-Johan opened this issue Oct 30, 2024 · 7 comments
Open
Assignees
Labels
bug Something isn't working v5

Comments

@LA-Johan
Copy link

LA-Johan commented Oct 30, 2024

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

iOS, Android

What happened?

Did not have new architecture turned on for 0.75.4. Version sheet version 5.0.5.

Code:

import React, { FC, PropsWithChildren, useEffect, useRef } from "react"
import { BottomSheetModal, BottomSheetScrollView, useBottomSheetSpringConfigs } from "@gorhom/bottom-sheet"
import { useSafeAreaInsets } from "react-native-safe-area-context"
import { DropdownProps } from "../../../shared-client/props/DropdownProps"
import { ReduceMotion, useReducedMotion, type WithTimingConfig } from "react-native-reanimated"
import { Platform } from "react-native"
import { dismissKeyboard } from "../../utils/keyboardUtils"
import { View } from "./View"
import { BACKGROUND_COLOR, OVERLAY_COLOR, TEXT_DARK, useColorString } from "../../../shared-client/constants/colors"

export const Dropdown: FC<DropdownProps> = ({ children, dropdownContent, openState: [open, setOpen] }) => {
  const bottomSheetModalRef = useRef<BottomSheetModal>(null)
  useEffect(() => {
    if (open) {
      bottomSheetModalRef.current?.present()
      dismissKeyboard()
    } else {
      bottomSheetModalRef.current?.dismiss()
    }
  }, [open])
  return (
    <>
      {children}
      <BottomSheetModal
        ref={bottomSheetModalRef}
        backgroundStyle={{ backgroundColor: useColorString(BACKGROUND_COLOR) }}
        handleIndicatorStyle={{ backgroundColor: useColorString(TEXT_DARK) }}
        enableDynamicSizing
        onDismiss={() => setOpen(false)}
        animationConfigs={useAnimationConfig()}
        backdropComponent={() => (
          <View
            laStyle={{ position: { top: 0, bottom: 0, left: 0, right: 0 }, flex: 1, background: OVERLAY_COLOR }}
            onTap={() => setOpen(false)}
          />
        )}
      >
        <InternalView>{dropdownContent}</InternalView>
      </BottomSheetModal>
    </>
  )
}

/*
  There's a bug in BottomSheet which means that sheets will fail to open when reduce motion is enabled. Manually
  providing an animation config with `reduceMotion: ReduceMotion.Never` fixes this, but it does introduce a bit
  of jank when dismissing the sheet. This is a tradeoff we're willing to make for the sake of sheets at least
  working when reduce motion is enabled.

  @see https://github.com/gorhom/react-native-bottom-sheet/issues/1560
*/
const useAnimationConfig = (): WithTimingConfig | undefined => {
  const reduceMotionEnabled = useReducedMotion()
  const overrideConfig = useBottomSheetSpringConfigs({
    damping: 500,
    stiffness: 1000,
    mass: 3,
    overshootClamping: true,
    restDisplacementThreshold: 10,
    restSpeedThreshold: 10,
    reduceMotion: ReduceMotion.Never,
  })
  return Platform.OS === "ios" && reduceMotionEnabled ? overrideConfig : undefined
}

const InternalView: FC<PropsWithChildren> = ({ children }) => {
  const insets = useSafeAreaInsets()
  return (
    <BottomSheetScrollView overScrollMode={"never"}>
      {children}
      <View laStyle={{ height: insets.bottom }} />
    </BottomSheetScrollView>
  )
}

Reproduction steps

Screenshot 2024-10-30 at 11 02 59 AM Screenshot 2024-10-30 at 10 59 40 AM Screenshot 2024-10-30 at 10 29 24 AM Screenshot 2024-10-30 at 10 29 20 AM

Could not reproduce in snack.

Reproduction sample

https://snack.expo.dev/vzyoxpZc5yzsyBqVLeISU

Relevant log output

No response

@LA-Johan LA-Johan added the bug Something isn't working label Oct 30, 2024
@gorhom gorhom self-assigned this Oct 30, 2024
@gorhom gorhom added the v5 label Oct 30, 2024
@K3vlarUK
Copy link

Have you managed to get any time on this @gorhom ? Having same issue trying out 0.76.1 from 0.75.3

@LA-Johan
Copy link
Author

Yes, I'm still seeing it on 0.76.1 as well. Let me know if I can provide any other information.

@fobos531
Copy link
Contributor

fobos531 commented Nov 1, 2024

it's worth nothing that this issue doesn't appear if dynamic sizing is turned off. So, likely a bug related to dynamic sizing.

@LA-Johan
Copy link
Author

LA-Johan commented Nov 1, 2024

@fobos531 I tried without dynamic sizing and still saw the issue (possible the hot reload didn't work and code was stale)

@vorn-dev-ni
Copy link

same same

@LA-Johan
Copy link
Author

@gorhom is it possible to get a status update on this issue?

@fobos531
Copy link
Contributor

Hello everyone, can you try the following fix to see if it fixes the issue for you?

#2010 (comment)

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

No branches or pull requests

5 participants