-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alert disappears when modal gets hidden (re-rendered with visible=false) #22237
Comments
This issue affects modal view controllers in general, not just alerts. |
I did some debugging and found that because the // viewController == RCTModalHostViewController instance
[viewController dismissViewControllerAnimated:animated completion:completionBlock]; which hides the alert view controller and the modal view controller remains visible. The documentation for Dismisses the view controller that was presented modally by the view controller. i.e. it dismisses the view controller presented by the receiver ( I think as a solution |
This patch fixes the dismissal of modals when there are view controllers presented on top of them: --- a/node_modules/react-native/React/Views/RCTModalHostViewManager.m
+++ b/node_modules/react-native/React/Views/RCTModalHostViewManager.m
@@ -89,7 +89,13 @@ RCT_EXPORT_MODULE()
if (_dismissalBlock) {
_dismissalBlock([modalHostView reactViewController], viewController, animated, completionBlock);
} else {
- [viewController dismissViewControllerAnimated:animated completion:completionBlock];
+ if (viewController.presentedViewController && viewController.presentingViewController) {
+ // Ask the presenting view controller to dismiss any view controllers presented on top of the modal host
+ // together with the host itself.
+ [viewController.presentingViewController dismissViewControllerAnimated:animated completion:completionBlock];
+ } else {
+ [viewController dismissViewControllerAnimated:animated completion:completionBlock];
+ }
}
} |
Hello there 👋 this issue seems to have been inactive for the past few weeks. Because of this, it's likely that the issue is not a high priority anymore or it has been solved by OP; for these reasons, we'll close it. But please, if it's actually still an issue with 0.59.5 please comment below and we can reopen it or please send us a Pull Request with a fix 😊 |
Present each alert (UIAlertController) in a separate window so that they are not affected by modals or other presented view controlelrs. This also allows one to display mulitple alerts on top of each other (it is sometimes useful). I basically copied a bunch of code from RCTDevLoadingView to chieve this. This patch fixes issue facebook#22237.
Environment
Description
On iOS when an alert is shown on top of a modal and you hide the modal (by changing its visible prop via state) the alert also gets dismissed at the same time.
Reproducible Demo
Demo project:
demo.zip
Video of the bug:
https://drive.google.com/file/d/1eV7p9F_GLZDMWeoVZJrkcGqOXhL8ViYR/view?usp=sharing
The text was updated successfully, but these errors were encountered: