Skip to content

Commit 7c463a1

Browse files
committed
Add partial fix allowing for presenting outer-modal from the inner one
1 parent e9c45df commit 7c463a1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

ios/RNSScreen.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ - (void)initCommonProps
8989
#if !TARGET_OS_TV
9090
_sheetExpandsWhenScrolledToEdge = YES;
9191
#endif // !TARGET_OS_TV
92+
NSLog(@"RNSScreenView alloc at %p with VC at %p", self, _controller);
9293
}
9394

9495
- (UIViewController *)reactViewController

ios/RNSScreenStack.mm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ - (void)initCommonProps
155155
// the header will render in collapsed state which is perhaps a bug
156156
// in UIKit but ¯\_(ツ)_/¯
157157
[_controller setViewControllers:@[ [UIViewController new] ]];
158+
NSLog(@"RNSScreenStackView alloc at %p with NavVC at %p", self, _controller);
158159
}
159160

160161
#pragma mark - helper methods
@@ -399,7 +400,17 @@ - (void)setModalViewControllers:(NSArray<UIViewController *> *)controllers
399400
afterTransitions();
400401
return;
401402
} else {
403+
NSLog(@"visibleViewController %p", self->_controller.visibleViewController);
402404
UIViewController *previous = changeRootController;
405+
UIViewController *visibleViewController = self->_controller.visibleViewController;
406+
if ([visibleViewController isKindOfClass:RNSScreen.class]) {
407+
RNSScreen *screen = (RNSScreen *)visibleViewController;
408+
if (screen.screenView.isModal && screen.presentingViewController != weakSelf) {
409+
// We have already presented a modal from different (nested) stack
410+
// So the first view controller to be used as presenting view controller should be the last current modal.
411+
previous = screen;
412+
}
413+
}
403414
for (NSUInteger i = changeRootIndex; i < controllers.count; i++) {
404415
UIViewController *next = controllers[i];
405416
BOOL lastModal = (i == controllers.count - 1);
@@ -424,6 +435,7 @@ - (void)setModalViewControllers:(NSArray<UIViewController *> *)controllers
424435
return;
425436
}
426437

438+
NSLog(@"%p is presenting %p modally", previous, next);
427439
[previous presentViewController:next
428440
animated:shouldAnimate
429441
completion:^{

0 commit comments

Comments
 (0)