Skip to content

fix(ios): gate index>=4 appear-select on >5-tab overflow#526

Open
davidecallegaro wants to merge 1 commit into
callstack:mainfrom
davidecallegaro:fix/tabappear-overflow-guard
Open

fix(ios): gate index>=4 appear-select on >5-tab overflow#526
davidecallegaro wants to merge 1 commit into
callstack:mainfrom
davidecallegaro:fix/tabappear-overflow-guard

Conversation

@davidecallegaro
Copy link
Copy Markdown

Summary

Fixes #525.

On iOS, TabAppearModifier force-selects any tab with index >= 4 in onAppear to sync selection for tabs nested under iOS's "More" overflow tab. That overflow only exists when there are more than 5 visible tabs. With exactly 5 tabs there is no More tab, yet the 5th tab (index 4) still matches index >= 4, so it steals the selection whenever its scene re-appears — most visibly when the tab bar is re-shown after a screen hid it via .hideTabBar — causing a phantom tab switch that JS can't correct (selectedPage is a value-diffed controlled prop).

Change

Gate the force-select on actual overflow (filteredItems.count > 5), so it only runs when a real "More" tab exists.

 #if os(iOS)
-  if context.index >= 4, context.props.selectedPage != context.tabData.key {
+  if context.props.filteredItems.count > 5, context.index >= 4, context.props.selectedPage != context.tabData.key {
     context.onSelect(context.tabData.key)
   }
 #endif

Behavior

  • >5 tabs (More menu): unchanged — the appear-sync still runs for overflowed tabs.
  • ≤5 tabs: the spurious force-select no longer fires, so the 5th tab stops hijacking the selection on re-appear.

Testing

Verified on a 5-tab app (@bottom-tabs/react-navigation + expo-router) with a real device build: returning from a tabBarHidden screen no longer jumps to the 5th tab; normal tab switching and the >5-tab More flow are unaffected.

TabAppearModifier force-selected any tab with index >= 4 on appear to sync
selection for tabs under the system More tab. That overflow only exists with
more than 5 visible tabs, so on a 5-tab bar the 5th tab (index 4) hijacked the
selection whenever its scene re-appeared (e.g. when the tab bar is re-shown
after .hideTabBar), causing a phantom tab switch that JS can't correct.

Gate the force-select on filteredItems.count > 5. Fixes callstack#525.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TabAppearModifier hijacks the 5th tab (index 4) selection when a hidden tab bar re-appears

1 participant