react / react/react-native

<Modal> Component Not Appearing Correctly in Component Tree

Đang mở
#49,717 3 bình luận 5 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Component: Modal Issue: Author Provided Repro Platform: iOS Type: New Architecture
Ngôn ngữ chính
C++
Star
127k
Fork
25.3k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
4

Mô tả

Description

NOTE: This bug was NOT present on the old architecture. As soon as I set newArch: enabled, this bug appeared.
Another note: I did not file this issue in react-navigation because I reproduced this in react navigation v6 and v7 and this bug only was present on both versions. It only appeared when I set newArch: enabled and it appears to be related to the <Modal /> component.

The repro provided below should be very easy to reproduce (refer to videos).

I have a modal component like so:

// app/screens/ConfirmationModal.tsx
import { Modal, View }  from "react-native"
// ...

<Modal visible={showModal}>
   <View style={$fullScreenStyle}>

   </View>
</Modal>

And I trigger the setShowModal(true), it is actually appearing behind my screen (or just not at all) in the new architecture instead of above.

// My screen in my Navigator
<Stack.Screen
   name="RandomScreen"
   component={Screens.RandomScreen}
   options={{
      presentation: "transparentModal", // This line appears to be causing the collision with the Modal component
      animation: "fade",
   }}
/>

On the component tree, I have this Modal component at the very top, so this should definitely not occur.

Steps to reproduce
  1. Clone the repro: https://github.com/ChristopherGabba/Modal_Repro
  2. Run yarn install
  3. Run npx expo run:ios
  4. When the app loads, tap on Open Modal button.
  5. When the modal appears tap on the Green Show react native modal button

What should happen here is a green full screen modal should appear but nothing happens at all.

  1. Comment out this line:
// app/navigators/AppNavigator.tsx

  <Stack.Screen
     name="Modal"
     component={ModalScreen}
     options={{
          // presentation: "transparentModal", // COMMENTING THIS LINE OUT THE MODAL WORKS
          animation: "fade",
     }}
  />

Go through the same sequence and it works just fine.

React Native Version

0.76.7

Affected Platforms

Runtime - iOS

Areas

Bridgeless - The New Initialization Flow

Output of npx @react-native-community/cli info
error Failed to load configuration of your project.
Config Validation Error: "project.ios.unstable_reactLegacyComponentNames" is not allowed
    at parseUserConfig (/Users/christophergabba/.npm/_npx/270969bc0f7612b1/node_modules/@react-native-community/cli-config/build/readConfigFromDisk.js:48:11)
    at readConfigFromDiskAsync (/Users/christophergabba/.npm/_npx/270969bc0f7612b1/node_modules/@react-native-community/cli-config/build/readConfigFromDisk.js:63:10)
    at async loadConfigAsync (/Users/christophergabba/.npm/_npx/270969bc0f7612b1/node_modules/@react-native-community/cli-config/build/loadConfig.js:141:22)
    at async setupAndRun (/Users/christophergabba/.npm/_npx/270969bc0f7612b1/node_modules/@react-native-community/cli/build/index.js:191:14)
    at async run (/Users/christophergabba/.npm/_npx/270969bc0f7612b1/node_modules/@react-native-community/cli/build/index.js:146:5)
christophergabba@ChristophersMBP Modal_Repro %
Stacktrace or Logs
N/A
Reproducer

https://github.com/ChristopherGabba/Modal_Repro

Screenshots and Videos

Here is a video of it working correctly when the presentation: "transparentModal" is commented out:

https://github.com/user-attachments/assets/298942b9-5f64-4f81-840f-463bc6778a83

Here is a video of it not showing up at all when presentation: "transparentModal" is NOT commented out:

https://github.com/user-attachments/assets/f38376f4-a14c-4796-98c9-63eac6808efa

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với Modal_Repro được liên kết, theo dõi app/navigators/AppNavigator.tsx và app/screens/ConfirmationModal.tsx; chạy yarn install và npx expo run:ios, sau đó tái hiện lỗi bằng kiến trúc mới. So sánh hành vi khi presentation: "transparentModal" được bật và khi bị chú thích; hoàn tất khi modal React Native xuất hiện phía trên màn hình trong khi tùy chọn đó vẫn được bật.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
ios, react-native, typescript
Lĩnh vực
mobile-dev
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.