Fix iPad RTL modal centering in RNSScreen #3326
Open
+13
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Right-to-left layouts on iPad expose a UIKit quirk: when a sheet-style modal is presented, UIKit wraps a presented modal inside a
UITransitionView
, and in RTL that container is mirrored, reporting a negative X origin. BecauseRNSScreenView
reused that mirrored frame, the React view kept the negative origin and the sheet remained shifted.This PR normalizes the modal’s frame inside
RNSScreen::viewDidLayoutSubviews
. Whenever the screen is presented natively, we align it with its transition container’s bounds, which keeps the sheet centered from the very first animation frame.Fixes react-navigation/react-navigation#12800.
Changes
UITransitionView
).Screenshots / GIFs
Before
The modal animates in and remains shifted to the right.
After
The modal animates in centered, with no offset.
Test code and steps to reproduce
Alternatively, apply the provided patch (see below).
I18nManager.forceRTL(true)
and18nManager.allowRTL(true)
.Patch
If you prefer using a patch instead of the branch, apply the following:
react-native-screens+4.16.0.patch
Checklist