Repository navigation
Use native tabs in WPTabBarController - #26439
Conversation
dbd0270 to
08aae20
Compare
jkmassel
left a comment
There was a problem hiding this comment.
From Claude: Approving. We ran this on iOS 18.6, 26.5 and 27.2 simulators. The tab bar behaves like trunk: tapping the selected tab still returns to its first screen and scrolls to the top, Reader keeps its tab bar background, and the Me avatar is dimmed when Me isn't selected on iOS 18. The nits are inline, and none of them blocks.
Follow-up, not blocking: please land #26301 soon after this. Before iOS 27, when the selected tab is replaced by a new tab with the same identifier, UIKit keeps returning the removed tab from selectedTab. In the app, logging out while on Reader (for example from the expired-token alert) with a self-hosted site still signed in leaves the signed-in Reader screens in memory until the user switches tabs. The screen itself is correct. Building each tab once and resetting its screens, as #26301 does, means a selected tab is never replaced.
Nit: the description is still the template, and the "ran the affected tests" box is unticked. A short summary and test plan would help whoever reads this later.
How this was checked
WPTabBarControllerTestsandRootViewCoordinatorTestson iOS 18.6, 26.5 and 27.2. Everything passes on 27.2.replacingNotificationsPreservesOtherTabsAndTheirStacksfails on 18.6 and 26.5 at line 62.- A temporary probe comparing the
viewControllersandtabsAPIs: the tab bar items are still the screens' owntabBarItems, and a reselect tap still callsshouldSelectTab:, pops to the first screen and callstabBar:didSelectItem:. - The Jetpack app, signed in, with real taps on iOS 27.2 and 18.6.
- The logout case on iOS 26.5: a temporary hook called the same logout as the expired-token alert's Log out button while Reader was selected. Before logout,
selectedTabwas the current Reader tab. After logout, it was the removed tab, and the old Reader screens were still alive. Switching to My Site released them.
| } | ||
|
|
||
| extension UITab { | ||
| func configureAccountAvatar(_ avatar: UIImage?, isSelected: Bool) { |
There was a problem hiding this comment.
Finding from Claude:
Nit: this repeats the avatar styling in UITabBarItem.configureAccountAvatar below it (26 pt Gravatar icon, dimmed copy before iOS 26, tab-bar-me fallback). A shared helper that returns the selected and dimmed images would keep the main app and the Reader app from drifting apart.
| } | ||
|
|
||
| @Test func programmaticSelectionUpdatesMinimization() throws { | ||
| guard #available(iOS 26, *) else { return } |
There was a problem hiding this comment.
Finding from Claude:
Nit: before iOS 26 this test returns early and is reported as passed without checking anything. A trait such as .enabled(if: ProcessInfo.processInfo.isOperatingSystemAtLeast(OperatingSystemVersion(majorVersion: 26, minorVersion: 0, patchVersion: 0))) would report it as skipped instead.
| #expect(controller.tabs[index] === originalTabs[index]) | ||
| } | ||
| #expect(controller.readerNavigationController.topViewController === detail) | ||
| #expect(controller.selectedTab?.viewController === controller.notificationsNavigationController) |
There was a problem hiding this comment.
Finding from Claude:
Nit: this expectation fails on iOS 18.6 and 26.5 simulators, and passes on 27.2, which CI uses. Before iOS 27, UIKit keeps returning the replaced tab from selectedTab even though the new tab is on screen. #26301 avoids replacing the tab, so this should pass everywhere once it lands. Until then, a short comment here would save someone a confusing local failure.
wpmobilebot
left a comment
There was a problem hiding this comment.
Approving. I ran the PR's WPTabBarControllerTests and RootViewCoordinatorTests plus my own probe tests, and drove the Jetpack app (signed in to WordPress.com) on an iPhone 18 Pro simulator with iOS 27.2 and an iPhone 17 Pro simulator with iOS 26.5. On both, the tab order, titles, notification dot and its "Notifications Unread" label, Me avatar and Reader tab bar background render correctly, with no truncation or overlap. Real taps still call tabBar:didSelectItem:, and tapping Reader again on a pushed screen pops back to the Reader root. The tab bar items are still the screens' own tabBarItems, so Reader's scrollEdgeAppearance and the UITab image and label updates reach the bar. The one Suggestion is inline. It only shows up before iOS 27, after a selected tab is replaced. All suites pass on 27.2. On 26.5, replacingNotificationsPreservesOtherTabsAndTheirStacks fails at line 62 for the same reason. Gap: Xcode 27.2 can't download an iOS 18 simulator runtime, so I couldn't check the pre-iOS 26 dimmed-avatar path.
| UINavigationController *navController = (UINavigationController *)viewController; | ||
| [navController scrollContentToTopAnimated:YES]; | ||
| } | ||
| if (tab != tabBarController.selectedTab) { |
There was a problem hiding this comment.
Suggestion: before iOS 27 this pointer check misclassifies a reselect after the selected tab is replaced. updateTabsSelecting: installs a new UITab with the same identifier. UIKit treats it as equal to the old one (isEqual: returns YES), so iOS 26.5 keeps returning the removed tab from selectedTab. The next tap on the visibly selected tab arrives here with the new tab, tab != tabBarController.selectedTab is true, and the code takes the "new tab" branch. It records another readerAccessed event and skips scrollContentToTopAnimated:. Trunk compared indexes, so this didn't happen there.
You can reach this by logging out of WordPress.com while Reader is selected and a self-hosted site keeps the app UI up (e.g. from the expired-token alert, via defaultAccountDidChange:), or when appUITypeDidChange flips shouldUseStaticNotifications while Notifications is selected. The impact is small: a duplicate analytics event and no scroll-to-top on that tap. UIKit still pops to the root. The same stale tab also feeds supportedInterfaceOrientations (selectedTab?.viewController).
Evidence:
- This probe test (kept locally) passes on iOS 27.2 and fails on iOS 26.5 with
count == 0failed (readerAccessedOnReselect=1):On 26.5,controller.showReaderTab() // window shown, staticReader: false NotificationCenter.default.post(name: .wpAccountDefaultWordPressComAccountChanged, object: nil) TestAnalyticsTracker.setup() let reader = try #require(controller.tab(forAppTab: .reader)) _ = controller.delegate?.tabBarController?(controller, shouldSelectTab: reader) #expect(TestAnalyticsTracker.tracked.filter { $0.stat == .readerAccessed }.count == 0)
controller.selectedTab === newReaderalso fails, whileoldReader.isEqual(newReader)is true. - In the Jetpack app on 26.5, a temporary hook posted the same notification while Reader was selected, then I tapped Reader again for real. The log here showed
shouldSelectTab=reader selected=reader same=0. On 27.2 it showedsame=1. On trunk with the same hook,selectedViewControllerwas the new Reader controller on both OSes.
Comparing identifiers (e.g. ![tab.identifier isEqualToString:tabBarController.selectedTab.identifier]) would fix the check here. Resolving selectedTab through tabForAppTab:self.selectedAppTab would also fix the orientation lookup. Building each tab once, as #26301 does, removes the cause.
There was a problem hiding this comment.
Resolved. At 4ab38a8, updateTabsSelecting: clears selectedTab before installing the replacement. I checked it on an iPhone 17 Pro simulator with iOS 26.5 and an iPhone 18 Pro with iOS 27.2:
- My reselect probe now passes on both: after the logout rebuild while Reader is selected,
selectedTabis the new Reader tab andreaderAccessedisn't recorded again. The PR'sreplacingNotificationsPreservesOtherTabsAndTheirStacks, which failed on 26.5 before, passes too. - In the Jetpack app, the same temporary hook rebuilt Reader while it was selected, then I tapped Reader again for real. On both OSes the log shows
shouldSelectTab=reader selected=reader same=1, and the Reader root is shown. - A spy probe found no side effects from the intermediate
nilselection: My Site and Me get noviewWillAppear, andselectedTabchangesnil→readeronly.
| if #available(iOS 26, *) { | ||
| image = icon | ||
| } else { | ||
| image = isSelected ? icon : icon.blackAndWhite?.withAlpha(0.36) |
There was a problem hiding this comment.
Nit: on iOS 18–25, every selection change now rebuilds the dimmed avatar: gravatarIcon(size:) plus the blackAndWhite CIFilter, which creates a new CIContext on every call. updateAccountAvatarForSelection runs from both setSelectedTab: and didSelectTab:previousTab:. Before, both images were built once, when the avatar changed. Building the full and dimmed icons in the avatar sink and only swapping them here would avoid repeating that work on the main thread. I couldn't measure this, because an iOS 18 simulator runtime isn't available for Xcode 27.2.
There was a problem hiding this comment.
Not resolved. 4ab38a8 doesn't change this code: updateAccountAvatarForSelection still rebuilds the dimmed avatar on each selection change before iOS 26. It's still optional, and I still couldn't measure it without an iOS 18 runtime.
Before iOS 27, UIKit keeps returning a removed tab from selectedTab when its replacement has the same identifier. Clearing the selection first makes the new tab the selection, so reselect tracking, scroll-to-top and orientation use it. Also report the iOS 26 minimization test as skipped on older systems.
wpmobilebot
left a comment
There was a problem hiding this comment.
Approving 4ab38a8. Clearing selectedTab before installing replacement tabs fixes the stale selection before iOS 27, and the intermediate nil doesn't show or load another tab. I ran WPTabBarControllerTests, RootViewCoordinatorTests and my probes on an iPhone 17 Pro simulator with iOS 26.5 and an iPhone 18 Pro with iOS 27.2, and all pass. I also rebuilt Reader while it was selected in the Jetpack app and tapped it again; the tap is handled as a reselect on both OSes. Gap: there's still no iOS 18 runtime for Xcode 27.2, so I couldn't check the pre-iOS 26 avatar path or confirm that the new @available(iOS 26, *) test is reported as skipped there.
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
Description
Migrate
WPTabBarControllerto the iOS 18UITabAPI, replacing index-based selection with stable destination identifiers.Tab updates reuse existing destinations and navigation controllers where possible, preserving unaffected navigation stacks when account changes replace a tab. The existing tab order, repeated-tap navigation, analytics, notification indicators, and avatar appearance are preserved.
What I ran
Testing instructions