react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

[V2][IOS] Alerts are not showing up after dissmissOverlay has been called.

Open michellmorso opened this issue 8 years ago • 11 comments

Issue Description

When dissmissOverlay is called , it screws up something in the screen order so that alerts show up behind your application and is thus not visible. This only happens in the IOS Simulator.

Steps to Reproduce / Code Snippets / Screenshots

  1. setup a new react-native project with react-native-navigation
  2. create 2 js files with these names: MainScreen and Overlay
  3. paste below code into the 3 js files.
  4. run-ios and click "Show Alert" button to see that the alert shows up.
  5. click "show overlay" and then click "close overlay"
  6. click "Show Alert" button again to see that its now not showing the alert

App.js

import { Navigation } from 'react-native-navigation';
import MainScreen from "./MainScreen";
import SomeOverlay from "./SomeOverlay";

Navigation.registerComponent("main_screen", () => MainScreen);
Navigation.registerComponent("some_overlay", () => SomeOverlay);

Navigation.events().registerAppLaunchedListener(() => {
    Navigation.setRoot({
        root: {
            component: {
                name: "main-screen"
            }
        }
    });
});

MainScreen.js

import React, {Component} from 'react';
import {View, Text, StyleSheet, Button, Alert} from 'react-native';
import {Navigation} from 'react-native-navigation';

export default class MainScreen extends Component {
    render() {
        return (
            <View style={{flex:1, justifyContent: "center", alignItems: "center"}}>
                <Button onPress={() => {Alert.alert("--Alert--")}} title="Show Alert" color="#841584"/>
                <Button onPress={() => {this.openOverlay()}} title="Show Overlay" color="#841584"/>
            </View>
        )
    }

    openOverlay(){
        Navigation.showOverlay({
            component: {
                name: 'overlay'
            }
        });
    }
}

SomeOverlay.js

import React, {Component} from 'react';
import {View, Text, StyleSheet, Button} from 'react-native';
import {Navigation} from 'react-native-navigation';

export default class SomeOverlay extends Component {
    render() {
        return (
            <View style={{flex:1, justifyContent: "center", alignItems: "center", backgroundColor:"#000"}}>
                <Text>This is an Overlay</Text>
                <Button onPress={() => {this.closeOverlay()}} title="Close Overlay" color="#841584"/>
            </View>
        )
    }

    closeOverlay(){
        Navigation.dismissOverlay(this.props.componentId);
    }

}

Environment

  • React Native Navigation version: 2.0.2578
  • React Native version: 0.57.2
  • Platform: IOS, havent tested Android
  • Device info: Debug, Simulator

michellmorso avatar Oct 18 '18 04:10 michellmorso

We have the same problem. It's not just the alerts, native components such as share modals are not working as well.

orkanylmz avatar Oct 31 '18 19:10 orkanylmz

@orkanylmz Which version of RNN are you using?

guyca avatar Nov 01 '18 10:11 guyca

@guyca React native version = 0.57.1, RNN = https://github.com/abdullah-sr/react-native-navigation#build, this fork

orkanylmz avatar Nov 01 '18 11:11 orkanylmz

@orkanylmz Try upgrading to latest version of RNN and see if it reproduces. We've done some work related to Overlays and alerts.

guyca avatar Nov 01 '18 12:11 guyca

@guyca Does the latest version master support 0.57.1 ?

orkanylmz avatar Nov 01 '18 12:11 orkanylmz

master is still on v1 which isn't supported. v2 can be found in v2 branch and it supports 0.57.x

guyca avatar Nov 01 '18 16:11 guyca

We're still experiencing this after upgrading to 2.1.3 with RNN and RN 0.55. For us, it's happening on a device too. If we dismissOverlay before Alert.alert, then the overlay disappears and the alert is shown. But if we Alert.alert, then dismissOverlay, the alert is never shown.

dvicory avatar Nov 15 '18 23:11 dvicory

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

stale[bot] avatar Dec 16 '18 00:12 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Dec 23 '18 02:12 stale[bot]

this is still a problem in v 2.4.0 of RNN

michellmorso avatar Jan 23 '19 19:01 michellmorso

this is still a problem in v 3.2.0 of RNN

phuongwd avatar Feb 04 '20 11:02 phuongwd