Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modal component does not support SafeAreaView bottom margin #18177

Closed
LutherBaker opened this issue Mar 3, 2018 · 32 comments
Closed

Modal component does not support SafeAreaView bottom margin #18177

LutherBaker opened this issue Mar 3, 2018 · 32 comments
Labels
Bug Priority: Mid Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@LutherBaker
Copy link

SafeAreaView bottom margin is not honored inside of a Modal on an iPhone X.

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 9.7.1
Yarn: 1.5.1
npm: 5.6.0
Watchman: 4.7.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.53.3 => 0.53.3

Expected Behavior

On an iPhone X, when a full screen component wrapped in a SafeAreaView renders correctly on the root view of the application, it should also render correctly when used inside of a Modal.

Actual Behavior

On an iPhone X, a full screen component wrapped in a SafeAreaView renders correctly on the root view of the application but it does not render correctly when used inside of a Modal.

Specifically, the HEADER margin is present but the FOOTER margin is missing. The full screen component goes to the bottom edge of the iPhone X (simulator).

Steps to Reproduce

  1. Run the Snack on an iPhone X simulator
  2. Find render() and note the two options (one with modal, one not)
  3. Comment the options appropriately and see the issue
  4. Remember, you need to run this on an iPhone X to see the problem

https://snack.expo.io/@lutherbaker/modal---safeareaview

@LutherBaker
Copy link
Author

SafeAreaView bottom margin is not being honored in a Modal

When components wrapped in SafeAreaView are rendered to the root view:

iphonex-root

When (the same) components wrapped in SafeAreaView are provided to a Modal:

iphonex-modal

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest stable release?

Thank you for your contributions.

How to ContributeWhat to Expect from Maintainers

@react-native-bot react-native-bot added Old Version Ran Commands One of our bots successfully processed a command. labels Mar 5, 2018
@LutherBaker
Copy link
Author

I upgraded to React Native 54.0 but the provided snack demonstration still holds. The bottom safe area margin is not honored within a Modal.

Environment:
OS: macOS Sierra 10.12.6
Node: 9.7.1
Yarn: 1.5.1
npm: 5.6.0
Watchman: 4.7.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: ^16.2.0 => 16.2.0
react-native: 0.54.0 => 0.54.0

@MrGurns
Copy link

MrGurns commented Mar 15, 2018

Subscribing

@ChrisJVoss
Copy link

I have the same issue. Modal overlays only the bottom SafeAreaView.

@damikdk
Copy link

damikdk commented Apr 17, 2018

You can use SafeAreaView from react-navigation. It works for me

import { SafeAreaView } from 'react-navigation';

@hyungtae3713
Copy link

it works for me thanks!

@zhanggeyi
Copy link

"SafeAreaView bottom margin is not being honored in a Modal" is still bothering me (react-native: 0.55.4)

@SwampThingTom
Copy link

Having the same issue here. The SafeAreaView in react-navigation is a nice workaround but React Native's built-in SafeAreaView should work.

@Jordan-Nelson
Copy link

I am seeing this issue on version 0.55.2

@aplex-dex
Copy link

Hi, guys. @damikdk, @hyungtae3713
We can use react-native-safe-area-view
instead of react-navigation. Because react-native-safe-area-view package is used inside react-navigation.

@bhardman1986
Copy link

Just as an update as of v 0.57.1 the issue still exists.

@erickjth
Copy link

I am having the same issue in 0.56.

@levibuzolic
Copy link
Contributor

levibuzolic commented Dec 5, 2018

Still exists in 0.57.x, here's an updated Snack with a toggle to show the behaviour of in/out of a modal and using the JS/native implementations without needing to be edited: https://snack.expo.io/@levibuzolic/modal---safeareaview

@alessiocancian
Copy link

@bhardman1986 @erickjth @levibuzolic for modals and absolute positioned views use SafeAreaView from react-navigation (instead of react-native) like said before

@hramos hramos removed the Bug Report label Feb 6, 2019
elelad added a commit to elelad/react-native that referenced this issue Feb 17, 2019
@alvarotala
Copy link

still a thing..

@michalchudziak
Copy link
Contributor

michalchudziak commented Mar 19, 2019

It works correctly with emulateUnlessSupported property. Without it, it's still broken. The issue is present on RNTester.

@cjpete
Copy link

cjpete commented Mar 29, 2019

Is there a recommended workaround for this? react-native-safe-area-view has some issues, and doesn't seem to be a straight replacement.

@nathggns
Copy link

nathggns commented Apr 3, 2019

This bug 100% still exists and is over a year old. Has anything been done on addressing this?

@michalchudziak what is the emulateUnlessSupported property?

@tncbbthositg
Copy link

What version of react-navigation's SafeAreaView fixed it for you guys? It's still broken for me with react-native's SafeAreaView and react-navigation's.

@oxy88
Copy link

oxy88 commented Apr 11, 2019

Is there any way I can use SafeAreaView with Modal ?

@ericlewis
Copy link
Contributor

Looking at this, and setSafeAreaInsets is being called often, without all of the actual values. I.e. only top value is returned, only bottom value is returned, multiple times. Doing this:

safeAreaInsets.bottom = safeAreaInsets.bottom == 0 ? safeAreaInsets.top : safeAreaInsets.bottom;

appears to fix the problem without anything weird, but seems like a hack. Will open a PR anyway.

@clanwce
Copy link

clanwce commented May 30, 2019

Still having issue with this.. Neither SafeAreaView from React Native nor the one from react-navigation is working for me.

@zhongwuzw
Copy link
Contributor

Anyone can try #25150?

kelset pushed a commit that referenced this issue Jun 19, 2019
Summary:
Fixes #18177 . Related #24497. Autoresizing mask would conflict with `AutoLayout`. For example , it would impact `SafeAreaView`. And actually we don't need to use autoresizing mask,  we observe the bounds change notification and [update the frame manually](https://github.com/facebook/react-native/blob/1151c096dab17e5d9a6ac05b61aacecd4305f3db/React/Views/RCTModalHostView.m#L59).

## Changelog

[iOS] [Fixed] - Removed autoresizing mask for modal host container view
Pull Request resolved: #25150

Differential Revision: D15645148

Pulled By: cpojer

fbshipit-source-id: 95d5f40feaa980b959a3de6e273dccac8158c57b
@adimshev
Copy link

Still not working (RN 0.59.9)

@nathggns
Copy link

@zhongwuzw
Copy link
Contributor

@adimshev Hey, 0.59.9 don't apply the patch, you can cherry pick #25150.

@adimshev
Copy link

Me too, but I want to use native SafeAreaView.

@adimshev
Copy link

Is it applied in 0.59.10 ?

@zhongwuzw
Copy link
Contributor

Still not, only in master branch and under test.

@adimshev
Copy link

Thank you!

And what about forceInset in native realization? Can we hope?

@caphun
Copy link

caphun commented Feb 10, 2020

I have an older version of ReactNative so got it to work like this:

import {SafeAreaView} from 'react-navigation'
...
<Modal>
  <SafeAreaView>
    ...
  </SafeAreaView>
</Modal>

Using:

  • react-native v0.59.10
  • react-navigation v3.11.1

@facebook facebook locked as resolved and limited conversation to collaborators Feb 10, 2020
M-i-k-e-l pushed a commit to M-i-k-e-l/react-native that referenced this issue Mar 10, 2020
Summary:
Fixes facebook#18177 . Related facebook#24497. Autoresizing mask would conflict with `AutoLayout`. For example , it would impact `SafeAreaView`. And actually we don't need to use autoresizing mask,  we observe the bounds change notification and [update the frame manually](https://github.com/facebook/react-native/blob/1151c096dab17e5d9a6ac05b61aacecd4305f3db/React/Views/RCTModalHostView.m#L59).

## Changelog

[iOS] [Fixed] - Removed autoresizing mask for modal host container view
Pull Request resolved: facebook#25150

Differential Revision: D15645148

Pulled By: cpojer

fbshipit-source-id: 95d5f40feaa980b959a3de6e273dccac8158c57b
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jun 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Priority: Mid Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.