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.

Top part (Handle component) bottomsheet slightly visible even the initial index value is set to -1

See original GitHub issue

Bug

The top part of bottomsheet (Handle component) slightly visible on screen mount even i already set the initial index value to -1. But when i close it from ref methods .close() it closed perferctly without any top part being visible. The issue only occur on the devices like Samsung S20.

Environment info

Library Version
@gorhom/bottom-sheet ^2
react-native 0.63.4
react-native-reanimated ^1.9.0
react-native-gesture-handler ^1.5.6

Steps To Reproduce

  1. I followed the example from this Dynamic height bottomsheet

Describe what you expected to happen:

  1. Top part bottomsheet should not be visible when the initial index props value is set to -1

Reproducible sample code

const [contentHeight, setContentHeight] = useState(0);
const snapPoints = useMemo(() => [0, contentHeight], [contentHeight]);
const easing = Easing.out(Easing.bezier(0.78, -0.4, 0.32, 1.6));
// Methods
const onLayoutSheetContainer = ({nativeEvent}) => {
  const layoutHeight = get(nativeEvent, 'layout.height', 0);
  setContentHeight(layoutHeight);
};
// Render
return (
  <BottomSheet
    index={-1}
    snapPoints={snapPoints}
    animationDuration={750}
    animationEasing={easing}
    handleComponent={HandleComponent}
    backdropComponent={BottomSheetBackdrop}
    backgroundComponent={BackgroundComponent}>
    <View
      style={styles.autoResizeContainer}
      onLayout={onLayoutSheetContainer}>
      {props.children}
    </View>
  </BottomSheet>
);

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
radko93commented, Jul 2, 2021

@gorhom I had the same issue on Pixel 4a, your fix works.

0reactions
ddikodroidcommented, Nov 7, 2021

Hi @gorhom I still facing this issue in v4 Here is the screenshot Screen Shot 2021-11-07 at 14 24 17

Here is the handle component

if (children) {
    return (
      <View style={[styles.baseContainer, styles.withChildren]}>
        <View style={styles.withChildrenText}>
          <Text style={styles.bottomSheetTitle}>{title}</Text>
          <Text style={styles.bottomSheetCloseTitle} onPress={onPressClose}>
            Tutup
          </Text>
        </View>
        {children}
      </View>
    );
  } else {
    return (
      <View style={[styles.baseContainer, styles.withoutChildren]}>
        <Text style={styles.bottomSheetTitle}>{title}</Text>
        <Text style={styles.bottomSheetCloseTitle} onPress={onPressClose}>
          Tutup
        </Text>
      </View>
    );
  }

const styles = StyleSheet.create({
  baseContainer: {
    paddingHorizontal: normalize(16),
    borderBottomWidth: 0.5,
    borderBottomColor: colors.light.grey,
    borderTopRightRadius: normalize(16),
    borderTopLeftRadius: normalize(16),
  },
  withChildren: {
    paddingBottom: normalize(8),
  },
  withChildrenText: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    paddingTop: normalize(12),
    paddingBottom: normalize(8),
  },
  withoutChildren: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    paddingVertical: normalize(12),
  },
  bottomSheetTitle: {
    ...fonts.bold,
    fontSize: normalize(16),
    lineHeight: normalize(24),
    color: colors.dark.darkerGrey,
  },
  bottomSheetCloseTitle: {
    ...fonts.bold,
    fontSize: normalize(16),
    lineHeight: normalize(24),
    color: colors.primary,
  },
});

I’ve tried to put topInset={StatusBar.currentHeight} but in the first render, the handle still visible

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you adjust the height and borderRadius of a ...
Default height for bottomSheet is half the screenSize. If you want your bottomSheet to EXPAND according to your content DYNAMICALLY.
Read more >
BottomSheetBehavior - Android Developers
An interaction behavior plugin for a child view of CoordinatorLayout to make it work as a bottom sheet. To send useful accessibility events, ......
Read more >
Sheets: bottom - Material Design
Bottom sheets are surfaces containing supplementary content that are anchored to the bottom of the screen.
Read more >
How to Use Buttons, Check Boxes, and Radio Buttons
First, this section explains the basic button API that AbstractButton defines ... At most one button in a top-level container can be the...
Read more >
Handling Scrolls with CoordinatorLayout - CodePath Cliffnotes
The first step is to make sure you are not using the deprecated ActionBar. Make sure to follow the Using the ToolBar as...
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