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.

Invisible bottom sheet gets stuck in the center of the screen on Android

See original GitHub issue

Hello,

The panel sometimes gets stuck in the middle of the screen on first app load. And it’s invisible. It prevents me from clicking on the map. Android only. iOS is ok.

I noticed that this happens when initialSnap reference to not maximal value. In my example: initialSnap = 0 works normally. And the panel is in it’s max size.

Map and panel components is on one level and wrapped in one flex container with no other params. Bug occurs more often on slow Android devices, or in debug mode.

const content = ({ children, height }) => (
  <View style={[styles.panel, { height }]}>
    {children}
  </View>
);

const renderHeader = () => (
  <View style={styles.header}>
    <View style={styles.panelHeader}>
      <View style={styles.panelHandle} />
    </View>
  </View>
);

const MapPanel = ({ panelRef, children, height }) => (
  <BottomSheet
    ref={panelRef}
    snapPoints={[600, 300, 0]}
    renderContent={() => content({ children, height })}
    renderHeader={renderHeader}
    initialSnap={2}
  />
);

Screenshot_1559676086

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:10

github_iconTop GitHub Comments

3reactions
WildSpycommented, Jun 22, 2019

I invented super-crutch 😃

make ref of a View in contentRender. I called it contentRef.

this is a try to define if panel is in wrong place and hide it. ‘top’ is a top snapPoint

function crutch() {
      contentRef.current.measure((width, height, px, py, fx, fy) => {
        if (fy < top) {
          return hidePanel();
        }
      });
}

but it not always work, that’s why i do this in componentDidMount

      if (Platform.OS === 'android') {
        // SUPERMEGA CRUTCH for Android
        const timerId = setInterval(crutch, 300);
        setTimeout(() => {
          clearInterval(timerId);
        }, 2000);
      }

i know it’s terrible 😦 but it works in my сase. waiting for the fix from the author

2reactions
WVandergriftcommented, Jul 31, 2019

Here’s what I ended up doing that has been working consistently so far (YMMV). I set the initial snap to the last snap point index. When the component mounts, I then set the desired snap position.

  componentDidMount() {
    // This is a shim to prevent the bottom sheet from occassionaly not rendering correctly.
    // https://github.com/osdnk/react-native-reanimated-bottom-sheet/issues/51
    this.bottomSheet.snapTo(1);
  }
        <BottomSheet
          ref={ref => { this.bottomSheet = ref; }}
          snapPoints={[420, 210, 40]}
          renderContent={this.renderPanelInner}
          renderHeader={this.renderPanelHeader}
          initialSnap={2}
          enabledInnerScrolling={false} />

Hopefully this will help someone else out until we can get an official fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bottom sheet stays on screen when activity is recreated
The issue I encountered is when user exists the app (with the bottom sheet expanded) and later comes back to the app, the...
Read more >
Modal Bottom Sheets - Material Design
BottomSheetBehavior works in tandem with CoordinatorLayout to let you display content on a bottom sheet, perform enter/exit animations, respond to dragging/ ...
Read more >
How to fix Maps when it crashes - Android - Google Maps Help
Clear storage in the Settings app on your device. Android iPhone & iPad.
Read more >
Android Bottom Sheet Behavior and Animated Button on Top ...
Bottom Sheets are surface components that hold supplementary content. It mostly anchored the bottom of the screen. In simple words, you can ...
Read more >
Troubleshooting | React Native Bottom Sheet - GitHub Pages
Pressables / Touchables are not working on Android​ ... Due to wrapping the content and handle with TapGestureHandler & PanGestureHandler , any gesture ......
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