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

Navigation.push in sideMenu doesn't respect bottomTabs visibility options #6989

Open markhomoki opened 3 years ago

markhomoki commented 3 years ago

🐛 Bug Report

Cannot hide bottomTabs when pushing to a new Bottom Tabs Screen from Side Menu. Using Navigation.push() from any other Bottom Tabs screens passes bottomTabs: { visible: false } but when calling from a Side Menu screen it does not. This used to work in v4, but started migrating to v7 this week and blocked by this issue.

Any help or pointing to the right direction is appreciated.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

Navigation.setRoot({
  root: {
    sideMenu: {
      left: {
        component: {
          id: 'SideMenu',
          name: 'Menu'
        }
      },
      center: {
        bottomTabs: {
          children: [{
            stack: {
              children: [{
                component: {
                  id: 'HOME_SCREEN',
                  name: 'Home'
                }
              }],
              options: {
                bottomTab: {
                  text: 'Home',
                  icon: require('./home.png')
                }
              }
            }
          }]
        }
      }
    }
  }
});

// calling this code from Side Menu won't apply visible: false
Navigation.push('HOME_SCREEN', {
  component: {
    name: 'Settings',
    options: {
      bottomTabs: {
        visible: false
      }
    }
  }
});

Tried to debug the native code and I believe the issue is related to topMostViewController, which got called in ReactNativeNavigation/RNNBasePresenter.m hidesBottomBarWhenPushed.

In that function, changing self.boundViewController.topMostViewController.resolveOptions to self.boundViewController.resolveOptions fixes the issue, but I'm afraid that it will have side effects.

When pushing inside Bottom Tabs from Bottom Tabs:

When pushing inside Bottom Tabs from Side Menu:

Because bottomTabs.visible: nil, the code relies on self.defaultOptions and during merge it sets bottomTabs.visible: YES.

Expected behavior

When using Navigation.push method should respect options property.

Actual Behavior

Passing options property to Navigation.push doesn't get applied when push happens from Side Menu screen.

Your Environment

yogevbd commented 3 years ago

This looks like an iOS bug where the system doesn't take hidesBottomBarWhenPushed into consideration when the first UITabBarController child is different than UINavigationController. Managed to reproduce it in a plain iOS project. I think that our best option is to add a workaround that will manually hide the bottomTabs in this specific case.

markhomoki commented 3 years ago

What would the best way to hide manually in that case? I tried to apply static options which didn't hide it. When I used Navigation.mergeOptions then it was a flash and the UX wasn't the same as navigating from a Bottom Tab screen.

Would it be an option to check somehow whether it's from sideMenu or not inside hidesBottomBarWhenPushed and use self.boundViewController.resolveOptions when navigating from sideMenu?

markhomoki commented 3 years ago

@yogevbd Is there anything you can recommend us looking into and potentially apply a fix? Upgrading Android fixed lot of issues for us and now we are maintaining 2 branches, which is not ideal. One for Android with upgraded RNN, and another one for iOS with the old RNN.

Any suggestions are welcome. We will try to allocate some time next week to solve this.

rocketplayfever commented 1 year ago

Same issue in 7.37.1 Any workarounds?