Skip to content

Update RNTester's tab content insets after the tab bar is laid out - #60369

Draft
ide wants to merge 2 commits into
react:mainfrom
expo:@ide/rntester-tab-content-insets-after-layout
Draft

ide wants to merge 2 commits into
react:mainfrom
expo:@ide/rntester-tab-content-insets-after-layout

Conversation

@ide

@ide ide commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Stacked on #60368 ("Contain RNTester's tab bar controller before its view enters a window"), which changes adjacent lines. Review only the last commit here.

RNTester's iOS tabs report the insets that the content must clear through onContentInsetsChange. They computed them only when the selected tab's safe area changed, from the tab bar's frame at that moment. The safe area can change before the tab bar controller's layout pass moves the bar, so the insets described the bar's previous position. After an unfolded iPhone Duo turned to portrait, where its side tab bar moves to the bottom, the bottom inset stayed 0 and the example list ran under the bar, where taps switch tabs.

This change also computes the insets after each layout pass of the tab bar controller, which a small UITabBarController subclass reports from viewDidLayoutSubviews. The safe area is read at that time instead of being passed by the callback.

Changelog:

[INTERNAL] [FIXED] - Compute RNTester's iOS tab content insets after the tab bar is laid out

Test Plan:

Ran:

node scripts/clang-format.js --check packages/rn-tester/RNTesterTabsIOS/ios/RNTesterTabsIOSComponentView.mm   # passes
git diff --check upstream/main                                                                                # clean

RNTester builds on this base with the change (2026-11-28, Xcode 27.1):

xcodebuild -workspace packages/rn-tester/RNTesterPods.xcworkspace -scheme RNTester -configuration Debug \
  -destination 'generic/platform=iOS Simulator' ARCHS=arm64 ONLY_ACTIVE_ARCH=YES CODE_SIGNING_ALLOWED=NO build

Not run: launching it. The check: on an iPhone Duo simulator, unfold RNTester in landscape and turn it to portrait, both while running and during launch. The last row of the example list ends above the tab bar; on main it runs under it. On an iPhone in portrait and landscape the content clears the status bar and tab bar as on main.

🤖 Generated with Claude Code

ide and others added 2 commits November 28, 2026 05:06
`RNTesterTabsIOSComponentView` installed its `UITabBarController`'s view
as its content view when it was created, so the view entered the window
with the component, and the controller became a child of the view
controller above only afterwards, in `didMoveToWindow`. UIKit's
containment rules ask for the opposite order.

On a physical iPhone Duo with iOS 27.2, launched unfolded, RNTester
sometimes came up with no tab items until it was sent to the background
and back. A likely cause is that the tab bar was laid out once by a
controller with no parent and again once it had one. That mechanism is
inferred, not confirmed.

Install the view only while the controller is a child, in the order
UIKit documents for container view controllers: `didMoveToWindow` adds
the controller to the view controller above, sizes and installs its
view, then calls `didMoveToParentViewController:`, and reverses that
when the component leaves the window.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
RNTester's iOS tabs computed their content insets only when the selected
tab's safe area changed, from the tab bar's frame at that moment. The
safe area can change before the tab bar controller's layout pass moves
the bar, so the insets described the bar's previous position. After an
unfolded iPhone Duo turned to portrait, where its side tab bar moves to
the bottom, the bottom inset stayed 0 and the list ran under the bar,
where taps switch tabs.

Also compute the insets after each layout pass of the tab bar
controller, which a `UITabBarController` subclass reports from
`viewDidLayoutSubviews`, and read the safe area at that time instead of
taking it from the callback.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant