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

[V2] Problems with push+dismissModal and showModal+pop

Open iksent opened this issue 8 years ago • 7 comments

Issue Description

If you do a pop for a modal screen or dismissModal for a pushed-screen, then problems start.

Steps to Reproduce / Code Snippets / Screenshots

  1. push new screen. Then call dismissModal. Result:
My screens Crash Crash (Drawer opened)
img_0017 img_0018 img_0019
  1. showModal new screen. Then call pop. Then call dismissModal. Result: nothing happens!

Environment

  • Checked with 3 versions of RNNv2: 2.0.2459, 2.0.2500, 2.0.2519
  • React Native version: 0.55.4
  • Platform(s) (iOS, Android, or both?): iOS only
  • Device info (Simulator/Device? OS version? Debug/Release?): Debug

My stack

Navigation.setRoot({
        root: {
            sideMenu: {
                left: {
                    component: {
                        id: SCREENS_NAMES.leftDrawer,
                        name: SCREENS_NAMES.leftDrawer
                    }
                },
                center: {
                    bottomTabs: {
                        children: navigationSettings.bottomTabs.map(t => ({
                            stack: {
                                children: [
                                    {
                                        component: {
                                            name: t.name,
                                            passProps: {
                                                ...(t.passProps || {})
                                            },
                                            options: {
                                                bottomTab: {
                                                    icon: getIconSource(t.icon),
                                                },
                                                topBar: {
                                                    visible: true,
                                                    title: {
                                                        text: t.title,
                                                    },
                                                },
                                            }
                                        }
                                    }
                                ],
                            }
                        })),
                    }
                }
            }

        }
    }).then(() => console.warn("App launched with RNN v2 =))"));

Where navigationSettings.bottomTabs is:

[
            {
                name: SCREENS_NAMES.testHome,
                title: 'Главная',
                icon: INITIALIZED_ICONS_NAMES.home,
                // ...
            },
            {
                name: SCREENS_NAMES.test,
                title: 'Test',
                icon: INITIALIZED_ICONS_NAMES.test,
                // ...
            },
        ]

iksent avatar Sep 04 '18 08:09 iksent

Hey @iksent Thanks for the detailed report. I'm wondering if awaiting the initial command resolves these issues.

We should probably add e2e to these use cases.

guyca avatar Sep 04 '18 08:09 guyca

@guyca, Hello.

So what should I check?

iksent avatar Sep 04 '18 08:09 iksent

Wait for the push command to complete

await Navigation.push(...);
Navigation.dismissModal();

guyca avatar Sep 04 '18 08:09 guyca

@iksent What exactly do you mean by "pop for a modal screen or dismissModal for a pushed-screen"? Modals can't be popped, they can be dismissed and pushed screens are popped.

guyca avatar Sep 05 '18 06:09 guyca

@guyca, "Modals can't be popped, they can be dismissed and pushed screens are popped." - Yes, you are right, but if you do such actions, navigation will behave inadequately. If you call showModal, after call pop or if you call push and after call dismissModal. I know, that such actions is not normal, but you should check, so that will not crash navigation.

iksent avatar Sep 05 '18 06:09 iksent

@yogevbd Lets talk about this issue, we should add e2e for these use cases as well.

guyca avatar Sep 05 '18 07:09 guyca

setting ...rightButtons: [{color: "#D84315", fontSize: 18}], inside setDefaultOptions-->topBar was crashing my app ..while calling .push or showModal ... everything back to normal after removing this property and adding color from static option

RajenderDandyal avatar Nov 27 '18 22:11 RajenderDandyal