Add a snapshot only if the Modal is visible (#42619)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42619

This is a workaround to prepare for the next diff in the stack and make sure that the modal works correctly

## Changelog
[iOS][Changed] - Add the for the dismissal snapshot only when we need it.

Reviewed By: sammy-SC

Differential Revision: D53003657

fbshipit-source-id: 6d6cc85946b1beb8e784e08a650d1247cf780228
This commit is contained in:
Riccardo Cipolleschi
2024-01-24 05:54:15 -08:00
committed by Facebook GitHub Bot
parent be441f8fbe
commit 7c4afa1006
@@ -165,7 +165,10 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct(
// To animate dismissal of view controller, snapshot of
// view hierarchy needs to be added to the UIViewController.
UIView *snapshot = _modalContentsSnapshot;
[self.viewController.view addSubview:snapshot];
if (_shouldPresent) {
[self.viewController.view addSubview:snapshot];
}
[self dismissViewController:self.viewController
animated:_shouldAnimatePresentation
@@ -194,7 +197,7 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct(
- (void)mountingTransactionWillMount:(const MountingTransaction &)transaction
withSurfaceTelemetry:(const facebook::react::SurfaceTelemetry &)surfaceTelemetry
{
_modalContentsSnapshot = [self.viewController.view snapshotViewAfterScreenUpdates:NO];
_modalContentsSnapshot = [self.viewController.view snapshotViewAfterScreenUpdates:YES];
}
#pragma mark - UIView methods