Skip to content

Commit a46a99e

Browse files
asafkoremfacebook-github-bot
authored andcommitted
fix(iOS): remove alert's window when call to hide. (#32833)
Summary: Resolves this issue: #32304. **NOTE:** This PR is based on a prior PR for this fix: #32305, I've co-authorized its creator for this change (paddlefish). 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`. The line after this change, set the `_alertWindow` reference to `nil`, but the window is already associated with a scene (see the screenshots from [this PR](#32305 (comment))). So we also need to remove the `windowScene` from that window, as recommended by Apple: https://developer.apple.com/documentation/uikit/uiwindowscene/3198091-windows. >To remove the window from the current scene, or move it to a different scene, change the value of the window's windowScene property. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [iOS] [Fixed] - remove alert's window when call to `hide`. Pull Request resolved: #32833 Test Plan: See #32305 Reviewed By: hramos Differential Revision: D33460430 Pulled By: lunaleaps fbshipit-source-id: b13c2c7ee6404f1e1c787265bc4af8a31005bcf1
1 parent 43e07a4 commit a46a99e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

React/CoreModules/RCTAlertController.m

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ - (void)show:(BOOL)animated completion:(void (^)(void))completion
3535

3636
- (void)hide
3737
{
38+
[_alertWindow setHidden:YES];
39+
40+
if (@available(iOS 13, *)) {
41+
_alertWindow.windowScene = nil;
42+
}
43+
3844
_alertWindow = nil;
3945
}
4046

0 commit comments

Comments
 (0)