From 3e09e59912b2f774061190f31bd38d6cf3baa53c Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 10 Mar 2025 11:20:33 -0700 Subject: [PATCH] Fabric: Fixes Modal snapshot when closing it (#48252) Summary: Fixes https://github.com/facebook/react-native/issues/48245 . The reason is we reuse the modal component and also reuse the snapshot of previous modal. ## Changelog: [IOS] [FIXED] - Fabric: Fixes Modal snapshot when closing it Pull Request resolved: https://github.com/facebook/react-native/pull/48252 Test Plan: Repro repo please see Fixes https://github.com/facebook/react-native/issues/48245 Reviewed By: rshest Differential Revision: D70629570 Pulled By: cipolleschi fbshipit-source-id: fe97184d2f27283a9c7e6df09e9df35630429ff1 --- .../ComponentViews/Modal/RCTModalHostViewComponentView.mm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm index 9205fa3d211..b53de29651c 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm @@ -104,7 +104,6 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct( BOOL _shouldAnimatePresentation; BOOL _shouldPresent; BOOL _isPresented; - UIView *_modalContentsSnapshot; } - (instancetype)initWithFrame:(CGRect)frame @@ -141,7 +140,6 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct( animated:(BOOL)animated completion:(void (^)(void))completion { - _modalContentsSnapshot = [self.viewController.view snapshotViewAfterScreenUpdates:NO]; [modalViewController dismissViewControllerAnimated:animated completion:completion]; } @@ -167,8 +165,7 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct( _isPresented = NO; // To animate dismissal of view controller, snapshot of // view hierarchy needs to be added to the UIViewController. - UIView *snapshot = _modalContentsSnapshot; - + UIView *snapshot = [self.viewController.view snapshotViewAfterScreenUpdates:NO]; if (_shouldPresent) { [self.viewController.view addSubview:snapshot]; }