Skip to content

[Bug]: Blur effect isn't applied to the background if handleComponent is set to null #2388

@thisisgit

Description

@thisisgit

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

iOS

What happened?

Hi, I'm seeing a bug where blur effect with expo blur view doesn't get applied on the background via backgroundComponent prop of the bottom sheet if handleComponent prop is set to null:

2.mp4

This doesn't always happen as you can see in the above recording, but it appears more frequently if the bottom sheet is loaded with heavier elements.

This used to work fine but started seeing this bug from version 5.1.6.
It looks like it happens when there's no element being rendered in handleComponent since

// this
handleComponent={() => null}
// and this
handleComponent={() => <View />}

result the same bug.

Reproduction steps

Minimal reproducible code:

import {
  BottomSheetModal,
  BottomSheetModalProvider,
  BottomSheetView,
} from '@gorhom/bottom-sheet';
import { BlurView } from 'expo-blur';
import React, { useCallback, useRef, useState } from 'react';
import { Button, StyleSheet, Switch, Text, View } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';

export const BottomSheetTest = () => {
  const bottomSheetModalRef = useRef<BottomSheetModal>(null);

  const [isToggled, setIsToggled] = useState<boolean>(false);

  const handlePresentModalPress = useCallback(() => {
    bottomSheetModalRef.current?.present();
  }, []);
  const handleSheetChanges = useCallback((index: number) => {}, []);

  return (
    <GestureHandlerRootView style={styles.container}>
      <BottomSheetModalProvider>
        <Button
          onPress={handlePresentModalPress}
          title="Present Modal"
          color="black"
        />
        <View style={styles.blurTestBox} />
        <BottomSheetModal
          ref={bottomSheetModalRef}
          handleComponent={() => <View />}
          backgroundComponent={({ style }) => (
            <BlurView style={style} intensity={50} tint={'light'} />
          )}
          onChange={handleSheetChanges}
        >
          <BottomSheetView style={styles.contentContainer}>
            <Text>Awesome 🎉</Text>
            <Switch value={isToggled} onValueChange={setIsToggled} />
            <View style={{ height: 400, width: '100%' }} />
          </BottomSheetView>
        </BottomSheetModal>
      </BottomSheetModalProvider>
    </GestureHandlerRootView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 24,
    justifyContent: 'center',
    backgroundColor: '#efefef',
  },
  contentContainer: {
    alignItems: 'center',
  },
  blurTestBox: {
    width: 100,
    height: 100,
    backgroundColor: 'blue',
  },
});

Reproduction sample

https://snack.expo.dev/@thisisgit/blurview-bottom-sheet-bug

Relevant log output

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedExtra attention is neededv5

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions