Skip to content

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

Merged
meta-codesync[bot] merged 1 commit into
react:mainfrom
expo:@ide/rntester-tab-bar-containment
Nov 30, 2026
Merged

meta-codesync[bot] merged 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 when it was created, and made the controller a child of the view controller above only later, in didMoveToWindow. UIKit's containment rules ask for the opposite order.

On an iPhone Duo simulator (iOS 27.1) launched unfolded, the last inset update at launch on main sees tabBar with a bottom bar's frame, {{0, 595}, {466, 83}}, although the bar on screen is on the side; with the controller contained first, every update sees the side bar. So on main RNTester applies a bottom bar's insets, 50 points at the top and 65 at the bottom instead of 16 and 0: the example list starts 34 points lower than with the side bar's insets, and every example page ends with 65 points of empty space. On a physical iPhone Duo (iOS 27.2), RNTester also sometimes came up with no tab items until sent to the background and back; that may have the same cause, but it did not reproduce on the simulator.

didMoveToWindow now follows the order UIKit documents for container view controllers: it adds the controller as a child, sizes and installs its view, then calls didMoveToParentViewController:, and reverses that when the component leaves the window. With no view controller above the component, the tabs are not installed; before, they showed without a parent controller.

Changelog:

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

Test Plan:

RNTester builds (Xcode 27.1). Run in Debug on an iPhone Duo (iOS 27.1, unfolded), an iPad Pro 13-inch (M5) and an iPhone 18 Pro (iOS 27.0) simulator.

On the iPhone Duo, a local log in tabSafeAreaInsetsDidChange shows the frames and insets above; on this branch every call sees the side bar ({{397, 0}, {69, 678}}). A local UI test measures:

  • The example list starts at y = 137 on main and y = 103 on this branch.
  • On the Button example page, scrolled to its end, the lowest text ends 158 points above the bottom of the window on main and 93 on this branch.
main This branch
Components list
End of the Button page
  • Over repeated launches of each build, the tab bar always had its three items.

On the iPhone 18 Pro and the iPad the frames are the same on both builds, and on the iPhone, turning to landscape and back keeps the list's last row above the tab bar.

@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
@ide
ide force-pushed the @ide/rntester-tab-bar-containment branch from df004a4 to 85200a3 Compare November 29, 2026 10:08
`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 an iPhone Duo launched unfolded, the last inset update at launch saw
the tab bar with a bottom bar's frame although it was on the side, so
RNTester applied a bottom bar's insets (50 points at the top, 65 at the
bottom). On a physical iPhone Duo (iOS 27.2) RNTester also sometimes
came up with no tab items; that may have the same cause.

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. With no view controller above
the component, the tabs are not installed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@ide
ide force-pushed the @ide/rntester-tab-bar-containment branch from 85200a3 to 26c4d17 Compare November 29, 2026 12:02
@ide
ide marked this pull request as ready for review November 29, 2026 13:49
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 29, 2026

@chrfalch chrfalch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The containment order looks right to me, in both directions. (Commenting rather than approving since it's still a draft.) Two requests:

1. Make the code comment match the evidence. The comment above didMoveToWindow says a tab bar laid out before its controller has a parent "can lose its items, as the iPhone Duo's side tab bar does". What the PR shows reproducibly is the wrong tabBar frame and the bottom-bar insets. The missing items were seen only sometimes on a physical device and not on the simulator, and the description itself says they only "may have the same cause". Could the comment describe the wrong frame and insets instead?

2. Before/after screenshots. The inset bug reproduces on every launch on the iPhone Duo simulator (unfolded). Screenshots from main and this branch would make the fix easy to see:

  • the top of the example list (y = 137 vs 103)
  • the end of an example page such as Button (the extra 65 points)

@meta-codesync

meta-codesync Bot commented Nov 30, 2026

Copy link
Copy Markdown

@javache has imported this pull request. If you are a Meta employee, you can view this in D135059659.

@zeyap zeyap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

ide added a commit to expo/react-native that referenced this pull request Nov 30, 2026
@ide

ide commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author
  1. The comment above didMoveToWindow now describes what was measured: "Installed before the controller had a parent, the iPhone Duo's side tab bar reported the frame of a bottom bar to the last inset update at launch." It no longer mentions missing items.
  2. The description now has screenshots from the iPhone Duo simulator (iOS 27.1, unfolded), main beside this branch: the Components list, which starts 34 points lower on main, and the end of the Button page, where main leaves the bottom bar's 65 points of padding.

@meta-codesync
meta-codesync Bot merged commit 19c49e3 into react:main Nov 30, 2026
107 of 108 checks passed
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @ide in 19c49e3

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Nov 30, 2026
@ide
ide deleted the @ide/rntester-tab-bar-containment branch December 1, 2026 05:30
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. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants