react-native-actions-sheet icon indicating copy to clipboard operation
react-native-actions-sheet copied to clipboard

Multiple action sheet issue on the same screen

Open mateattilabarna opened this issue 4 years ago • 4 comments

I tried to insert two action sheets in my screen, here is my code:

export class HomeScreen extends React.Component {
  actionSheetRef;
  plainActionSheetRef;

  constructor(props: any) {
    super(props);
    this.actionSheetRef = createRef<ActionSheet>();
    this.plainActionSheetRef = createRef<ActionSheet>();
  }

  render() {
    return (
      <View
        style={{
          justifyContent: 'center',
          flex: 1,
        }}
      >
        <TouchableOpacity
          onPress={() => {
            this.actionSheetRef.current?.setModalVisible();
          }}
        >
          <MFText>Open First ActionSheet</MFText>
        </TouchableOpacity>
        <TouchableOpacity
          onPress={() => {
            this.plainActionSheetRef.current?.setModalVisible();
          }}
        >
          <MFText>Open Second ActionSheet</MFText>
        </TouchableOpacity>

        <ActionSheet
          ref={this.actionSheetRef}
          extraScroll={34}
          gestureEnabled={true}
        >
          <MFText>first action sheet - row 1</MFText>
          <MFText>first action sheet - row 2</MFText>
          <MFText>first action sheet - row 3</MFText>
          <MFText>first action sheet - row 4</MFText>
        </ActionSheet>

        <ActionSheet
          key="asd"
          ref={this.plainActionSheetRef}
          extraScroll={34}
          gestureEnabled={true}
        >
          <MFText>second action sheet - row 1</MFText>
          <MFText>second action sheet - row 2</MFText>
          <MFText>second action sheet - row 3</MFText>
          <MFText>second action sheet - row 4</MFText>
        </ActionSheet>
      </View>
    );
  }
}

I tried also in functional component and class based component. The issue is that the extraScroll parameter doesn't work for the secondly opened action sheet:

1 2

extra info: It's the same issue, if i don't use the extraScroll parameter, so in case of the first action sheet i can scroll up, but for the second the scrolling up doesn't work. (scrolling down -> hiding the action sheet always works).

Can I ask you help, what could be wrong? Or I can't use two ActionSheet components in one screen?

mateattilabarna avatar May 13 '21 09:05 mateattilabarna

@ammarahm-ed if you could take a look at the issue I would really appreciate it! Thank you in advance!

mateattilabarna avatar May 13 '21 09:05 mateattilabarna

@mateattilabarna what are you trying to achieve here. i don't see a problem. can you share a video to demonstrate the problem. You can simply use containerStyle prop to add bottom padding to ActionSheet so the content doesn't hide.

ammarahm-ed avatar May 20 '21 07:05 ammarahm-ed

@ammarahm-ed

Sorry for the late answer, here is a video:

https://user-images.githubusercontent.com/19281761/121666362-723fce00-caa9-11eb-9703-cb31de69596b.mov

Extra info: I currently resolved with hiding totally one of the action sheets, so this is not blocking me.

mateattilabarna avatar Jun 11 '21 09:06 mateattilabarna

Looks like this issue can be resolved @ammarahm-ed 🎉

Fixed.

ammarahm-ed avatar Aug 21 '22 06:08 ammarahm-ed