Repository navigation
Conversation
Alternative: Simplify and just handle the cross axis instead?The result we've ended up with is now similar to simply scoping down our Duo-intended padding additions to the cross-axis only — and we could consider narrowing/reverting. Counterpoints:
System bars are an extension of the insets problem we were already solving — just a special case which I missed until this was tested in a real app. |
|
I might want to rephrase the doc comments tomorrow for clarity, but opening for review first. |
|
Open pick requests to 0.88 for the ScrollView stack of changes were closed. We're focusing on holistically shipping this + blog post comms in 0.89. |
cipolleschi
left a comment
There was a problem hiding this comment.
Approving: this restores padding in the common navigation and tab bar cases. The edge case noted inline is non-blocking and can be addressed in a follow-up.
| CGRect frame = [view convertRect:view.bounds toView:nil]; | ||
| CGRect bounds = window.bounds; | ||
| return UIEdgeInsetsMake( | ||
| MAX(0, insets.top - CGRectGetMinY(frame)), |
There was a problem hiding this comment.
Non-blocking edge case for a follow-up: an ancestor scaled above 1 can expand the converted frame beyond the window and overestimate the window-only inset. In a UIKit probe on an iOS 27 simulator, a full-screen UIScrollView under a UINavigationController, with an ancestor scaled to 1.2 and contentInsetAdjustmentBehavior set to always, retains a 116 pt top adjustment while this helper returns 149.4 pt. RCTWindowSafeAreaContentInset then keeps the 116 pt adjustment, so 20 pt of content-container padding is still absorbed despite the navigation bar.
A follow-up could bound the estimate to the window safe-area contribution UIKit actually propagates and add a native regression test. The added C++ test supplies the already-classified inset, so it does not exercise this helper.
…vigation and tab bars
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D133527191. |
Summary
Context
Follow-up to #59836, which is on
0.89-stable.Problem
With
contentInsetAdjustmentBehavior, #59836 lays out each edge at the larger of thecontentContainerStylepadding and the safe area inset.This is ideal for iPhone Duo / iPhone landscape horizontal insets. However, for the scrollable axis (when vertical), UIKit's inset also covers any system navigation bar, tab bar or toolbar the scroll view sits under. In this case, absorbing padding smaller than the bar is unexpected — a screen under a native stack header (react-native-screens, Expo Router) or above a tab bar loses its top or bottom padding.
(Below image is a mock explainer):
This diff
Apply the larger-of rule along the scrollable axis only on an edge where the window's safe area (the status bar, sensor housing or home indicator) alone makes up the inset. Where a bar adds to it, the padding adds on top, as in earlier releases:
automaticPhrased another way: Auto-positioning under a system header turns off inset vs padding behaviour. For vertical, this would now only take effect for a full screen view.
ScrollViews not against the system edges (e.g. already in a SafeAreaView or under an opaque custom header), are unchanged.
Changes
contentInsetAdjustmentBehaviorandcontentContainerStyledocs to match.Changelog:
[iOS][Fixed] - ScrollView: With
contentInsetAdjustmentBehavior,contentContainerStylepadding adds to an inset that includes a navigation bar, tab bar or toolbar, instead of being absorbed by itTest Plan
Set up temporarily in RNTester: the full screen ScrollView example under a native navigation bar, with 20 pt padding (green).
(Ignore white gap above the navigation bar, this is a separate Duo bug.)
RCTScrollViewComponentView.mmcompiles in an RNTester simulator build.ScrollContentViewTest.cpp: addedkeepsColumnPaddingBelowANavigationBar.