ammarahm-ed / react-native-actions-sheet

A Cross Platform(Android, iOS & Web) ActionSheet with a flexible api, native performance and zero dependency code for react native. Create anything you want inside ActionSheet.
https://rnas.vercel.app
MIT License
1.46k stars 121 forks source link

Strange behavior of action sheet on android #383

Open JaifDev opened 1 month ago

JaifDev commented 1 month ago

https://github.com/user-attachments/assets/7a7bb582-3212-4700-8f14-486a2923b3f0

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 commented 1 month ago

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

ammarahm-ed commented 1 month ago

Import FlatList from react-native-actions-sheet.

ed-sparkes commented 1 month ago

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 commented 2 weeks ago

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 commented 2 weeks ago

Import FlatList from react-native-actions-sheet.

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