React-native-navigation: [V2] Screen orientation bug

Created on 26 Sep 2018  路  9Comments  路  Source: wix/react-native-navigation

Issue Description

There is a bug which only appears on tab based apps (as far as I investigate). When we set the orientation option, it doesn't affect to the activity for the first time we open the app. Let me explain more.

Let's assume we set layout object like this.

layout: {
  backgroundColor: 'white',
  orientation: ['portrait']
}

The expected behavior is prevent the app to switch to landscape mode, right? It doesn't happen for the first time unfortunately, screen does rotate wether we set orientation option or not. What I mean by "first time" is, the first time we open and see the tab based app. When we open the tab based app and switch to another tab or go to another screen and try again to rotate the screen, It doesn't rotate, whole app starts to act like we expected.

Sum: orientation option doesn't affect to the app when we start tab based app.

Steps to Reproduce / Code Snippets / Screenshots

  • Set default option { layout: { orientation: ['portrait'] } }
  • Start tab based app
  • Rotate the screen to landscape (it will rotate)
  • Rotate to portrait (optional)
  • Switch to another tab or go to another screen
  • Rotate again (it will not rotate as expected)

Environment

  • React Native Navigation version: latest@v2
  • React Native version: 0.56
  • Platform(s) (iOS, Android, or both?): Android 8.1
  • Device info (Simulator/Device? OS version? Debug/Release?): Device, Debug
Android acceptebug v2 馃彋 stale

Most helpful comment

It seems like on Android, the setDefaultOptions does not get affected at all. And only becomes effective once react-native reloads or push to the next screen.

I have

Navigation.setDefaultOptions({
  topBar: {
    elevation: 0
  }
})

But the very first root coming from Navigation.setRoot does not get affected by this and as soon as I reload React Native or push to the next screen, the style come in effect.

  • React Native Navigation version: 2.0.2571
  • React Native version: 0.56.1
  • Platform: Android

All 9 comments

i have the same issue...

It seems like on Android, the setDefaultOptions does not get affected at all. And only becomes effective once react-native reloads or push to the next screen.

I have

Navigation.setDefaultOptions({
  topBar: {
    elevation: 0
  }
})

But the very first root coming from Navigation.setRoot does not get affected by this and as soon as I reload React Native or push to the next screen, the style come in effect.

  • React Native Navigation version: 2.0.2571
  • React Native version: 0.56.1
  • Platform: Android

@guyca I think this is a real bug

@jinshin1013 I have exactly the same issue with topBar elevation property. But for example statusBar property works properly for me on Android.

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.

The issue has been closed for inactivity.

Hi @guyca I see this issue marked as done, but I'm facing this with my current project, is there any hint to properly used the layout orientation?

version react-native 0.59.1
version react-native-navigation ^2.14.0

thanks

(update)
my bad, I just put the wrong options to the screen, it's supposed to be on the stack

thanks anyway

Hi! yes the issue for orientation is not resolve yet! help please:

"react-native": "0.57.7",
"react-native-navigation": "^2.16.0",

Hey guys, have you tried removing orientation from the configChanges options in _AndroidManifest.xml_?
From
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
to
android:configChanges="keyboard|keyboardHidden|screenSize"

Was this page helpful?
0 / 5 - 0 ratings