Skip to content

Contain RNTester's tab bar controller before its view enters a window - #60368

Draft
ide wants to merge 1 commit into
react:mainfrom
expo:@ide/rntester-tab-bar-containment
Draft

ide wants to merge 1 commit into
react:mainfrom
expo:@ide/rntester-tab-bar-containment

Conversation

@ide

@ide ide commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary:

RNTester's iOS tabs are a UITabBarController hosted in RNTesterTabsIOSComponentView. The component installed the controller'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 the component's didMoveToWindow. UIKit's containment rules ask for the opposite order: the controller becomes a child before its view is added.

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 side tab bar was laid out once by a controller with no parent and again once it had one. That mechanism is inferred from the code and the symptom; it was not confirmed, and this branch alone has not been run on that device.

This change installs 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.

Changelog:

[INTERNAL] [FIXED] - Contain RNTester's iOS tab bar controller before its view enters the window

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 on an iPhone, an iPad and an iPhone Duo (folded, and unfolded in both orientations). The tabs appear and switch on each, and on the physical iPhone Duo with iOS 27.2 repeated unfolded launches no longer come up without tab items. With a breakpoint or log in the tab bar controller's viewWillAppear:, parentViewController is set; on main it is nil. The missing tab items themselves have only been seen on a physical iPhone Duo with iOS 27.2; the iOS 27.1 simulator keeps the items either way.

🤖 Generated with Claude Code

`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>
@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