wix / react-native-navigation

A complete native navigation solution for React Native
https://wix.github.io/react-native-navigation/
MIT License
13.04k stars 2.67k forks source link

Diference in behavior from android vs iOS for the `RNN.ComponentWillAppear` event #7906

Open iurysza opened 3 months ago

iurysza commented 3 months ago

What happened?

Hello there!

If a user has a partially visible modal open (with the overCurrentContext flag) and then sends the app to the background, when bringing it back to the foreground it triggers two willAppear events in React Native. One event is for the modal, and the other is for the modal's parent view.

This is how we listen to the event:

  Navigation.events().registerComponentWillAppearListener(({ componentId }) => {}

This issue is specific to Android. On iOS, only one event is sent, which is related to the modal.

It seems that on Android, these events are triggered by the onGlobalLayout callback at./viewcontrollers/viewcontroller/ViewController.java:308, and not the onHostResume call stack.

While this could be interpreted as intended behavior, iOS only emits one event for the partially visible modal and none for the parent view.

What was the expected behaviour?

Our expectation was that both platforms should behave the same way: either by sending only one event for the top most view or one event for each view that is visible or partially visible.

Was it tested on latest react-native-navigation?

In what environment did this happen?

React Native Navigation version: 7.38.3 React Native version: 0.72.9 Has Fabric (React Native's new rendering system) enabled: (yes/no): NO Node version: 18.17 Device model: Pixel 8 Pro Android version: Android 14