React-native: iOS: Modal not showing in landscape orientation

Created on 20 Nov 2016  路  6Comments  路  Source: facebook/react-native

Description

Modal component in iOS does not show the modal in landscape mode when the screen is in landscape mode. The screen is rotated back to portrait mode.
GIF: https://gfycat.com/BronzeSparseJunebug

Reproduction

I have provided code so that you can reproduce the bug here:
https://github.com/saigrandhi/modal_bug

Solution

I am willing to work on this bug but would like some guidance on where to start.

Additional Information

  • React Native version: 0.37.0
  • Platform: iOS
  • Operating System: MacOS
Locked

Most helpful comment

i found that this is not a bug, as shown on the doc Modal section
https://facebook.github.io/react-native/docs/modal.html
we need to set the supportedOrientation prop of the Modal to ['portrait', 'landscape']
in order for Modal to support landscape mode in iOS

      <Modal
        visible={true}
        supportedOrientations={['portrait', 'landscape']}
      >
      </Modal>

All 6 comments

Yeah, Modal doesn't support this very well. Have you tried using something else? Unless you are building a hybrid application, it will be much easier to use normal View components inside the main react view. You can use ExNavigation or something similar for this use case.

Because you probably don't need to use Modal, I would consider this a feature request that can be posted on product pains. That way the rest of the community can vote on it and get the attention of the core RN team if it is important.

If want to fix this and your solution is isolated to RCTModalHostView* files, then we can probably get it reviewed pretty quickly.

Thanks for showing me where to fix this.

I have been looking through those files and it seems that a commit has been made that is specific to this issue. I will update my project to v0.38.0-rc.1 and see if it works.

i found that this is not a bug, as shown on the doc Modal section
https://facebook.github.io/react-native/docs/modal.html
we need to set the supportedOrientation prop of the Modal to ['portrait', 'landscape']
in order for Modal to support landscape mode in iOS

      <Modal
        visible={true}
        supportedOrientations={['portrait', 'landscape']}
      >
      </Modal>

@sckoh +1, that solves the issue. Thanks.

Cool that helps, but on android it works without this attribute in portrait and landscape mode!

@sckoh ,

Thank you. Works perfect!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

josev55 picture josev55  路  3Comments

despairblue picture despairblue  路  3Comments

DreySkee picture DreySkee  路  3Comments

axelg12 picture axelg12  路  3Comments

lazywei picture lazywei  路  3Comments