Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion React/Views/RCTModalHostViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ - (void)dismissModalHostView:(RCTModalHostView *)modalHostView withViewControlle
if (_dismissalBlock) {
_dismissalBlock([modalHostView reactViewController], viewController, animated, completionBlock);
} else {
[viewController dismissViewControllerAnimated:animated completion:completionBlock];
[viewController.presentingViewController dismissViewControllerAnimated:animated completion:completionBlock];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation is clear and confirms my recollections:

dismissViewControllerAnimated:completion:

Dismisses the view controller that was presented modally by the view controller.
SDKs

So, the fix looks perfectly legit to me, the only Q that prevents me from landing it:
I don't understand how/why it worked previously. Did it? (Until we find answer to this question we cannot be sure that our conclusions are correct.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shergin Could be why it works, but maybe it dismisses the wrong vc sometimes.

 If you call this method on the presented view controller itself, UIKit asks the presenting view controller to handle the dismissal.

Thanks for clarifiying what reactViewController is. LGTM

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we just have one Modal, it works whatever we passed presented VC or presenting VC, but if we have multiple Modals, bug may happen, for example, VC present Modal A, ModalA present Modal B, if we call [ModalA dismissVC], what this should perform? because ModalA is the presenting VC to present ModalB,but it also the presented VC which presenting VC is the closest VC when present ModalA, I think this is why bug happened. :)

}
}

Expand Down