Prevent iOS Alert and Modal from rendering in the top-left corner#57251
Open
zoontek wants to merge 2 commits into
Open
Prevent iOS Alert and Modal from rendering in the top-left corner#57251zoontek wants to merge 2 commits into
zoontek wants to merge 2 commits into
Conversation
Contributor
|
I never saw this happening tbf. Is this happening consisntely @zoontek ? |
Contributor
Author
|
@cortinico No, it's not consistent. It's a timing/race so it's hard to reproduce on demand, but I've hit it myself and got reports from users too (also, see #45453). |
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.
Summary:
On iOS, both
AlertandModalcould render in the top-left corner of the screen instead of filling it.RCTAlertController: when the alert window is created from aUIWindowScene, it was initialized without a frame and defaulted to a zero-sized frame. We now set its frame to the scene's coordinate space bounds.ModalHostViewUtils:ModalHostViewScreenSizeusedRCTScreenSize(), whose value is cached once viadispatch_once. If that first read happens before the screen is ready, it caches0and stays0, so the modal renders zero-sized in the top-left corner. We now readRCTViewportSize()on the main queue, which reads the key window's bounds live.Fixes #45453
Changelog:
[IOS] [FIXED] - Prevent Alert and Modal from rendering in the top-left corner
Test Plan:
Alerton iOS and confirm it is centered and correctly sized.Modalon iOS and confirm it fills the screen instead of appearing in the top-left corner.Screenshots: