Skip to content

Commit 3a0c402

Browse files
okwasniewskifacebook-github-bot
authored andcommitted
fix(iOS): modal swipe dismissal works only for the first time (#53499)
Summary: This PR fixes swipe dismissal to work each time the modal is shown. Previously modalInPresentation was set on the view controller which gets destroyed every time user dismisses the modal. This makes sure that modal in presentation is correctly preserved when showing multiple modals. https://github.com/user-attachments/assets/c7f140e5-1c4f-4809-8453-148d4becc9eb ## Changelog: [IOS] [FIXED] - modal swipe dismissal works only for the first time Pull Request resolved: #53499 Test Plan: 1. Open RN Tester 2. Check allow swipe dismissal 3. Check closing it multiple times Reviewed By: javache Differential Revision: D81312918 Pulled By: cipolleschi fbshipit-source-id: 4f7cc60762660e5d5310f4973fe8df340c1ba52b
1 parent 87a1b51 commit 3a0c402

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ @implementation RCTModalHostViewComponentView {
106106
BOOL _shouldAnimatePresentation;
107107
BOOL _shouldPresent;
108108
BOOL _isPresented;
109+
BOOL _modalInPresentation;
109110
}
110111

111112
- (instancetype)initWithFrame:(CGRect)frame
@@ -115,6 +116,7 @@ - (instancetype)initWithFrame:(CGRect)frame
115116
_shouldAnimatePresentation = YES;
116117

117118
_isPresented = NO;
119+
_modalInPresentation = YES;
118120
}
119121

120122
return self;
@@ -126,7 +128,7 @@ - (RCTFabricModalHostViewController *)viewController
126128
_viewController = [RCTFabricModalHostViewController new];
127129
_viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
128130
_viewController.delegate = self;
129-
_viewController.modalInPresentation = YES;
131+
_viewController.modalInPresentation = _modalInPresentation;
130132
}
131133
return _viewController;
132134
}
@@ -152,6 +154,7 @@ - (void)ensurePresentedOnlyIfNeeded
152154
if (shouldBePresented) {
153155
[self saveAccessibilityFocusedView];
154156
self.viewController.presentationController.delegate = self;
157+
self.viewController.modalInPresentation = _modalInPresentation;
155158

156159
_isPresented = YES;
157160
[self presentViewController:self.viewController
@@ -276,7 +279,8 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
276279
self.viewController.modalPresentationStyle = presentationConfiguration(newProps);
277280

278281
if (oldViewProps.allowSwipeDismissal != newProps.allowSwipeDismissal) {
279-
self.viewController.modalInPresentation = !newProps.allowSwipeDismissal;
282+
_modalInPresentation = !newProps.allowSwipeDismissal;
283+
self.viewController.modalInPresentation = _modalInPresentation;
280284
}
281285

282286
_shouldPresent = newProps.visible;

0 commit comments

Comments
 (0)