Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iOS): invalid orientation of contained modals #2011

Merged
merged 5 commits into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,22 @@ - (void)layoutSubviews
{
[super layoutSubviews];
_controller.view.frame = self.bounds;

// We need to update the bounds of the modal views here, since
// for contained modals they are not updated by modals themselves.
for (UIViewController *modal in _presentedModals) {
// Because `layoutSubviews` method is also called on grabbing the modal,
// we don't want to update the frame when modal is being dismissed.
// We also want to get the frame in correct position. In the best case, it
// should be modal's superview (UITransitionView), which frame is being changed correctly.
// Otherwise, when superview is nil, we will fallback to the bounds of the ScreenStack.
BOOL isModalBeingDismissed = [modal isKindOfClass:[RNSScreen class]] && ((RNSScreen *)modal).isBeingDismissed;
tboba marked this conversation as resolved.
Show resolved Hide resolved
CGRect correctFrame = modal.view.superview != nil ? modal.view.superview.frame : self.bounds;

if (!CGRectEqualToRect(modal.view.frame, correctFrame) && !isModalBeingDismissed) {
modal.view.frame = correctFrame;
}
}
}

- (void)dismissOnReload
Expand Down
Loading