Commit 859bdb8
Prevent iOS Alert and Modal from rendering in the top-left corner (#57251)
Summary:
On iOS, both `Alert` and `Modal` could render in the top-left corner of the screen instead of filling it.
- `RCTAlertController`: when the alert window is created from a `UIWindowScene`, 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`: `ModalHostViewScreenSize` used `RCTScreenSize()`, whose value is cached once via `dispatch_once`. If that first read happens before the screen is ready, it caches `0` and stays `0`, so the modal renders zero-sized in the top-left corner. We now read `RCTViewportSize()` 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
Pull Request resolved: #57251
Test Plan:
- Open an `Alert` on iOS and confirm it is centered and correctly sized.
- Open a `Modal` on iOS and confirm it fills the screen instead of appearing in the top-left corner.
## Screenshots:
<img width="284" height="542" alt="Alert" src="https://github.com/user-attachments/assets/e98ae159-9752-4b6e-8a97-0276984af3ba" />
<img width="284" height="542" alt="Modal" src="https://github.com/user-attachments/assets/1fff4217-5f28-4017-8699-01b757e7fb8a" />
Reviewed By: javache
Differential Revision: D109310703
Pulled By: cortinico
fbshipit-source-id: db3d66a704921c524faed62d82695528d75698eb1 parent b29dc96 commit 859bdb8
2 files changed
Lines changed: 12 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
383 | 384 | | |
384 | 385 | | |
385 | 386 | | |
386 | | - | |
387 | | - | |
388 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
389 | 391 | | |
390 | 392 | | |
391 | | - | |
| 393 | + | |
| 394 | + | |
392 | 395 | | |
393 | | - | |
| 396 | + | |
394 | 397 | | |
395 | 398 | | |
396 | 399 | | |
397 | | - | |
| 400 | + | |
398 | 401 | | |
399 | | - | |
| 402 | + | |
400 | 403 | | |
401 | 404 | | |
402 | 405 | | |
403 | | - | |
| 406 | + | |
404 | 407 | | |
405 | 408 | | |
406 | 409 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
0 commit comments