Skip to content

Commit 05c4321

Browse files
okwasniewskifacebook-github-bot
authored andcommitted
fix: fallback alert controller to UIScreen size (#53500)
Summary: This PR falls back to UIScreen when windowScene is not available. <img width="500" alt="CleanShot 2025-08-28 at 14 30 59@2x" src="https://github.com/user-attachments/assets/9dda3153-dfe7-48a5-9d0e-5416c2e34c64" /> ## Changelog: [IOS] [FIXED] - Simplify RCTAlertController, don't create additional UIWindow Pull Request resolved: #53500 Test Plan: Open the alert multiple times to check if everything works as expected. Rollback Plan: Reviewed By: javache Differential Revision: D81410450 Pulled By: cipolleschi fbshipit-source-id: c27ea98d9e811c2f259f0ff3c6689482d116c418
1 parent 61deab7 commit 05c4321

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

packages/react-native/React/CoreModules/RCTAlertController.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ @implementation RCTAlertController
2020
- (UIWindow *)alertWindow
2121
{
2222
if (_alertWindow == nil) {
23-
_alertWindow = [[UIWindow alloc] initWithWindowScene:RCTKeyWindow().windowScene];
23+
UIWindowScene *scene = RCTKeyWindow().windowScene;
24+
if (scene != nil) {
25+
_alertWindow = [[UIWindow alloc] initWithWindowScene:scene];
26+
} else {
27+
_alertWindow = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
28+
}
2429

2530
if (_alertWindow) {
2631
_alertWindow.rootViewController = [UIViewController new];

0 commit comments

Comments
 (0)