Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Panel isn't on top - zIndex issue #179

Open
hoc-ht opened this issue Jun 20, 2020 · 4 comments
Open

Panel isn't on top - zIndex issue #179

hoc-ht opened this issue Jun 20, 2020 · 4 comments

Comments

@hoc-ht
Copy link

hoc-ht commented Jun 20, 2020

Issue Description

I think there is a zIndex issue. I tried a very simple example, but it seems the Show Panel button is overlap the panel.

image

Steps to Reproduce / Code Snippets / Screenshots

import React from 'react';
import {View, Button, Text} from 'react-native';

import SlidingUpPanel from 'rn-sliding-up-panel';

const styles = {
  container: {
    flex: 1,
    backgroundColor: 'white',
    alignItems: 'center',
    justifyContent: 'center'
  }
};

class MyComponent extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Button title='Show panel' onPress={() => this._panel.show()} />
        <SlidingUpPanel ref={c => this._panel = c}>
          <View style={styles.container}>
            <Text>Here is the content inside panel</Text>
            <Button title='Hide' onPress={() => this._panel.hide()} />
          </View>
        </SlidingUpPanel>
      </View>
    )
  }
}

export default MyComponent;

Environment

  • Version: 2.4.2
  • React Native version: 0.62.2
  • Platform(s) (iOS, Android, or both?): Android
  • Device info (Simulator/Device? OS version? Debug/Release?): Simulator - Android 9
@octopitus
Copy link
Owner

Move the <Button title='Show panel' onPress={() => this._panel.show()} /> to below the panel should fix the issue. The reason is Button component on Android has elevation which sometime mess up with zIndex.

@benjamindulau
Copy link

benjamindulau commented Nov 27, 2020

Same here. Moving the button below the panel doesn't resolve the issue. Other ideas? 🙄

Rendering the button in a different view works though.

The following works:

<SafeAreaView style={styles.wrapper}>
    <StatusBar style="auto" translucent/>
    <View style={styles.container}>
        <Button title='Show panel' onPress={this.handleClickShowPanel} />
    </View>
    <SlidingUpPanel ref={this.panelRef} backdropOpacity={0.75} allowDragging={false}>
        <View style={styles.panelContainer}>
            <Text>Here is the content inside panel</Text>
            <Button title='Hide' onPress={this.handleClickHidePanel} />
        </View>
    </SlidingUpPanel>
</SafeAreaView>

Compared to:

<SafeAreaView style={styles.wrapper}>
    <StatusBar style="auto" translucent/>
    <View style={styles.container}>
        <Button title='Show panel' onPress={this.handleClickShowPanel} />
        <SlidingUpPanel ref={this.panelRef} backdropOpacity={0.75} allowDragging={false}>
            <View style={styles.panelContainer}>
                <Text>Here is the content inside panel</Text>
                <Button title='Hide' onPress={this.handleClickHidePanel} />
            </View>
        </SlidingUpPanel>
    </View>
</SafeAreaView>

@elmcapp
Copy link

elmcapp commented Oct 15, 2021

Im having same issue. I have a card component that covering the panel.

I move components around a stated but does not help. This only happens on Android. Also I notice on android the sliding is not smooth when using this._panel. only smooth slide when using finger to slide.

The main problem is that the slider is not on top when using with android

@elmcapp
Copy link

elmcapp commented Oct 15, 2021

I figured out a workaround. I don't like it but it works. Two options

option 1 move the slider component to the top level of your app
Screen Shot 2021-10-15 at 5 24 22 PM

Option 2 is to use a Provider and Portal which will bring any component that is wrap up to the top level making it appear over all other components.

Screen Shot 2021-10-15 at 5 24 31 PM

I did this using React Native Paper Portal and Provider
https://callstack.github.io/react-native-paper/portal.html

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants