If view extends beyond window boundaries, do not add that difference to the insets#177
Merged
janicduplessis merged 1 commit intoAppAndFlow:masterfrom Mar 7, 2021
Conversation
janicduplessis
approved these changes
Mar 7, 2021
Collaborator
janicduplessis
left a comment
There was a problem hiding this comment.
This seems fine, I think the insets should never be bigger than the element it is insetting. This seems consistent with the behavior I've observed on iOS too.
This was referenced Mar 8, 2021
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #176
This may not be the ideal fix... I'm open to other options. Perhaps it should consider the scenario of the view extending beyond the window boundaries to simply be "invalid" and return
null?? Perhaps there's something I'm missing in the intended behavior here?Summary
The problem is described in detail in #176. The short version is that, during rotation on Android there's a transitional phase where the window's dimensions have been updated according to the rotation but the view's have not, so the view might extend beyond the height or width of the window. The current calculations in
getSafeAreaInsetswere adding this difference in dimensions to the normal insets and returning extremely large insets.Test Plan
I have not tested with a device/app that actually renders under a cutaway or home/back buttons and uses the safe area insets to lay out elements accordingly. This change seems pretty simple/safe in that regard to me, but I'm trusting reviewers/maintainers to say if it looks risky to them. (the status of the "example" app is unclear to me... it doesn't look like it actually uses
react-native-safe-area-context??)I have tested with a "normal" device/app, and verified that rotating the device no longer produces super-large insets.
(this code could probably use a comment, but I wasn't sure if I understood it well enough to write a useful one...)