Skip to content

Conversation

@mdjastrzebski
Copy link
Contributor

@mdjastrzebski mdjastrzebski commented Dec 11, 2025

Summary:

Resolves #54856
Resolves #50152

Fixes a but when RCTModalHostViewController tries to dismiss itself using the following code:

- (void)dismissViewController:(UIViewController *)modalViewController
                     animated:(BOOL)animated
                   completion:(void (^)(void))completion
{
  [modalViewController dismissViewControllerAnimated:animated completion:completion];
}

But since it's already presenting another VC on top of it (e.g., login web view VC, photo picker VC, etc), it dismisses that view but not itself, which results in a transparent modal VC (all the UI is unmounted) that is the top VC blocking all touch input.

image

The change is minimal: instead of calling dismissViewControllerAnimated:completion: on modalViewController, which has two different behaviors depending on whether that VC is presenting another VC, it calls it on modalViewController.presentingViewController, which has a unique behavior of dismissing modalViewController.

Changelog:

Test Plan:

  1. Run Modal examples in the RN Tester app to confirm that this code still works ok in the base case.
  2. Run the reproducer from [iOS] ModalHostViewController not properly dismissed if presenting another VC #54856 with and without the change to confirm this code fixes the issue.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 11, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Dec 11, 2025
@mdjastrzebski
Copy link
Contributor Author

Danger change is failing due to non-related error: https://github.com/facebook/react-native/actions/runs/20138652296/job/57799224046

@mdjastrzebski mdjastrzebski force-pushed the fix/modal-dismissal-when-presenting-other-native-modal branch from e8109aa to 68adedf Compare December 29, 2025 09:49
@mdjastrzebski
Copy link
Contributor Author

mdjastrzebski commented Dec 29, 2025

This also fixes the bug mentioned in #54781:

The first is when dismissing and presenting different modals in parallel, when we do this we end up in a weird state where the second modal is not presented and seems to block the UI from receiving touches.

without introducing stacked modals or any breaking change.

@mdjastrzebski mdjastrzebski force-pushed the fix/modal-dismissal-when-presenting-other-native-modal branch from 68adedf to b16e101 Compare January 5, 2026 16:31
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. It should be safe... but you'll never know with our internal apps and tests. 🤞

@meta-codesync
Copy link

meta-codesync bot commented Jan 5, 2026

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D90118522.

@mdjastrzebski
Copy link
Contributor Author

NB: The failing workflow does not seem related to the changes:

0curl: (6) Could not resolve host: central.sonatype.com

@cipolleschi
Copy link
Contributor

Some internal comments from @javache :

This should already be equivalent

If you call this method on the presented view controller itself, UIKit asks the presenting view controller to handle the dismissal.
https://developer.apple.com/documentation/uikit/uiviewcontroller/dismiss(animated:completion:)


Can we have a reproducer for this in RNTester?
It's very easy for this to cause other regressions. Really, dismissing a modal that's currently presenting another modal is not something we should be doing anyway.

@lodev09
Copy link

lodev09 commented Jan 9, 2026

@cipolleschi IOS supports undimmed sheets. It's very possible to have a use-case where user will dismiss the modal when there's a UISheetPresentationController presented. Here's a duplicate PR I did for this issue #55005

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

4 participants