Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Strange behavior of action sheet on android #383

Open
JaifDev opened this issue Jul 26, 2024 · 6 comments
Open

Strange behavior of action sheet on android #383

JaifDev opened this issue Jul 26, 2024 · 6 comments

Comments

@JaifDev
Copy link

JaifDev commented Jul 26, 2024

WhatsApp.Video.2024-07-26.at.12.22.35_00367ff3.mp4

The action sheet magically disappears after appearing.

`import React, { useRef } from "react";
import { StyleSheet, Text, View } from "react-native";
import ActionSheet, {
  ActionSheetRef,
  SheetProps,
} from "react-native-actions-sheet";
import {
  widthPercentageToDP as wp,
  heightPercentageToDP as hp,
} from "react-native-responsive-screen";

import { COLORS, FONT, SIZES } from "../../constants/theme";
import { StudentDataType, studentHomework } from "@/constants/studentData";
import { TouchableOpacity, FlatList } from "react-native-gesture-handler";

const CheckHomeworkStudent = (props: SheetProps<"checkHomeworkStudent">) => {
  const actionSheetRef = useRef<ActionSheetRef>(null);

  const { payload } = props;
  const { selectedStudent, getStudentById } = payload!;

  const renderStudent = ({ item }: { item: StudentDataType }) => {
    return (
      <TouchableOpacity
        activeOpacity={0.6}
        style={[
          styles.studentInfo,
          selectedStudent === item.id && { backgroundColor: COLORS.extraLight },
        ]}
        onPress={() => {
          getStudentById(item.id);
          actionSheetRef?.current?.hide();
        }}
      >
        <Text style={styles.studentName}>{item.studentName}</Text>
        <Text style={styles.classInfo}>
          Class: {item.class}, Section: {item.section}
        </Text>
      </TouchableOpacity>
    );
  };

  return (
    <ActionSheet
      id={props.sheetId}
      ref={actionSheetRef}
      drawUnderStatusBar={false}
      indicatorStyle={{
        width: wp(20),
        marginVertical: hp(1),
        backgroundColor: COLORS.white,
      }}
      gestureEnabled={true}
      containerStyle={{
        height: hp(75),
        backgroundColor: COLORS.sheetColor,
      }}
      useBottomSafeAreaPadding={false}
    >
      <View style={styles.container}>
        <Text style={styles.title}>Select Student</Text>
      </View>
      <FlatList
        data={studentHomework}
        renderItem={renderStudent}
        keyExtractor={(item) => item.id.toString()}
        nestedScrollEnabled={true}
      />
    </ActionSheet>
  );
};

export default CheckHomeworkStudent;

const styles = StyleSheet.create({
  container: {
    paddingHorizontal: wp(3),
    paddingVertical: hp(1),
  },
  title: {
    fontFamily: FONT.bold,
    color: COLORS.white,
    fontSize: SIZES.l,
    maxWidth: wp(50),
  },
  btn: {
    width: wp(93),
    justifyContent: "center",
    alignItems: "center",
    backgroundColor: COLORS.primary,
    borderRadius: wp(2),
    paddingVertical: hp(2),
  },
  btnTxt: {
    fontFamily: FONT.medium,
    color: COLORS.white,
    fontSize: SIZES.m,
  },
  studentInfo: {
    marginBottom: hp(1),
    borderRadius: wp(3),
    borderWidth: wp(0.3),
    borderColor: COLORS.extraLight,
    paddingHorizontal: wp(5),
    paddingVertical: wp(2),
  },
  studentName: {
    fontSize: wp(5),
    fontFamily: FONT.medium,
    color: COLORS.white,
  },
  classInfo: {
    fontSize: wp(4),
    fontFamily: FONT.medium,
    color: COLORS.white,
  },
});`

In Android with New Architectrure Enabled.

@ammarahm-ed
Copy link
Owner

Can you try and reproduce this issue in the example app? Does this issue happen only when new arch is enabled?

@ammarahm-ed
Copy link
Owner

ammarahm-ed commented Aug 1, 2024

Import FlatList from react-native-actions-sheet.

@ed-sparkes
Copy link

Seeing very similar result on Android even with gestureEnabled={false} scrolling around the view the action sheet some times disappears or goes really small but the overlay remains across the whole screen

i decided to just disabled gestures on android but even then getting very weird rendering behaviour when i start scrolling

@JaifDev
Copy link
Author

JaifDev commented Aug 23, 2024

Seeing very similar result on Android even with gestureEnabled={false} scrolling around the view the action sheet some times disappears or goes really small but the overlay remains across the whole screen

i decided to just disabled gestures on android but even then getting very weird rendering behaviour when i start scrolling

Wierd, I am still getting this error on a new app

@JaifDev
Copy link
Author

JaifDev commented Aug 23, 2024

Import FlatList from react-native-actions-sheet.

Tried it too, it's only happening on new architecture

@Medkhat
Copy link

Medkhat commented Oct 19, 2024

Hi there! See this issue: #321

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

No branches or pull requests

4 participants