From 37670956c0c9aba5bcc758fac9b74cec85b1f41a Mon Sep 17 00:00:00 2001 From: Asaf Korem Date: Wed, 5 Jan 2022 17:28:04 +0200 Subject: [PATCH] fix(iOS): remove alert's window when call to `hide`. Resolves this issue: #32304. Without this change, calling to hide an alert, leaves a `UIWindow` that blocks user interactions with the screen. The correct way to remove a `UIWindow` in iOS is to set its hidden property to `YES`. Also, it is required to remove all references to the window (the associated `windowScene` for example) and ARC will automatically free this `UIWindow`. Co-authored-by: paddlefish --- React/CoreModules/RCTAlertController.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/React/CoreModules/RCTAlertController.m b/React/CoreModules/RCTAlertController.m index 7b326a2ad31ee8..2465e62cc2a97e 100644 --- a/React/CoreModules/RCTAlertController.m +++ b/React/CoreModules/RCTAlertController.m @@ -35,6 +35,12 @@ - (void)show:(BOOL)animated completion:(void (^)(void))completion - (void)hide { + [_alertWindow setHidden: YES]; + + if (@available(iOS 13, *)) { + _alertWindow.windowScene = nil; + } + _alertWindow = nil; }