question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cant click whats under the bottom sheet when adding backdrop

See original GitHub issue

Bug

When I add a back drop component to the bottom sheet, I canot click on anything bellow the bottom sheet, even when backdrop is closed. Tryed to add enableTouchThrough={true} to backdrop but it didnt help.

Environment info

| @gorhom/bottom-sheet | ^2.2.4 | | react-native | 0.63.4 | | react-native-reanimated | ^1.13.2 | | react-native-gesture-handler | ^1.9.0 |

Steps To Reproduce

  1. Create a screen with a button.
  2. Add bottom sheet and have 2 snap points, one on 20% and one on 70% (never on 0).
  3. Add backdrop comopnent to be presented only when the bottom sheet is on 70%.
  4. Try to click the button, when to bottom sheet is on 20% (the first snap point).

Describe what you expected to happen:

  1. The button should be clicked.

what happend:

  1. the button is not clicked.

Reproducible sample code

import React, { useRef } from 'react';
import styled from 'styled-components/native';
import BottomSheet, {
  BottomSheetBackdrop,
  BottomSheetBackdropProps,
  BottomSheetBackgroundProps,
} from '@gorhom/bottom-sheet';
import { View } from 'react-native';

const StyledBackdrop = (props: BottomSheetBackdropProps) => {
  return (
    <BottomSheetBackdrop
      {...props}
      closeOnPress={false}
      enableTouchThrough={true}
    />
  );
};

const snapDrawerPoints = [168, 470];

export const BottomDrawer = ({ children }: { children?: React.ReactNode }) => {
  const bottomSheetRef = useRef<BottomSheet>(null);

  return (
    <BottomSheet
      ref={bottomSheetRef}
      backdropComponent={StyledBackdrop}
      snapPoints={snapDrawerPoints}>
        <Container>{children}</Container>
    </BottomSheet>
  );
};

const Container = styled.View`
  flex: 1;
  margin: 20px 20px 0 20px;
`;


Edit

Found out it works fine for some devices and doesnt work for others. Works fine on pixel 4 for example, and doesnt work for oneplus 8 and galaxy note 20 ultra. Wasnt tested on iPhone.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

10reactions
mulholland-cccommented, May 10, 2021

@AmirDebbie @oneji @ShaunLWM

I had the same issue on the iPhone. Adding pointerEvents='none' to the Animated.View in the example solved this for me.

const Backdrop = ({ animatedIndex, style }: BottomSheetBackdropProps) => {
  // animated variables
  const containerAnimatedStyle = useAnimatedStyle(() => ({
    opacity: interpolate(
      animatedIndex.value,
      [0, 1],
      [0, 1],
      Extrapolate.CLAMP
    ),
  }));

  // styles
  const containerStyle = useMemo(
    () => [
      style,
      {
        backgroundColor: colors.pulp,
      },
      containerAnimatedStyle,
    ],
    [style, containerAnimatedStyle]
  );

  return <Animated.View pointerEvents='none' style={containerStyle} />;
};

export default Backdrop;

Hope this helps.

0reactions
alexpchincommented, Sep 15, 2022

I don’t think this actually resolves the problem. Using a different backdrop is a bit of a workaround not, solving the issue with enableTouchThrough not enabling BottomSheetBackdrop to receive pointer events…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why am I able to click "behind" the bottomsheet in Android?
A simple solution is to add the. android:clickable="true". attribute to the layout that you are using for your bottom sheet. That way it...
Read more >
Change background and apply visual effects in Google Meet
Open the Meet app Meet app and then select a meeting. · Before you join, on the bottom of your self view, tap...
Read more >
Use Background Images in Your Views - Tableau Help
In the Background Images dialog box, click Add Image. In the Add Background ... Click the Add button at the bottom of the...
Read more >
5 Examples of the new Ionic 6 Bottom Sheet Modal
For now we need to focus on the presentation of the modal, and to get the bottom sheet you have to set the...
Read more >
Video: Remove a watermark - Microsoft Support
Training: Can't figure out how to remove a watermark, because you can't find where it is? ... Want more? Add a background picture...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found