Description: Verifies the preventNativeSelection prop on TabsScreen, which
blocks the native tab selection gesture for a given tab. When enabled, tapping
the tab in the tab bar — or selecting it from the "More" list on iOS — will be
blocked. The TabsHost fires an onTabSelectionPrevented event with the key
of the prevented screen, allowing JS to handle the attempt (e.g. show a toast
or dialog). The test validates that the prop can be toggled at runtime, that
the callback is called correctly, that programmatic navigation via selectTab
is not affected, and that the "More" navigation controller on iOS is also
subject to prevention.
OS test creation version: iOS: 18.6 and 26.2, Android: 16.0 (Baklava).
Yes: Partially automated. The E2E test covers most steps for iPhone and Android phone.
- iPad specific steps are not automated, as the resize interactions required to trigger the More tab (Split View / window resizing between compact and regular size classes) are not feasible with Detox.
- Testing repeated selection of an already active More tab is not currently automated (Step 19 from the scenario). When the More tab content is already active and displayed, Detox is unable to re-select the "More" tab bar item because it becomes invisible for Detox.
- iOS device or simulator: iPhone and iPad
- Android emulator
- For iOS each of the below steps (except iPad only) must be executed twice: once on iPhone and once on iPad.
- On iOS with 6 tabs, the tab bar shows only the first 4 tabs plus a More item. The Fifth and Sixth tabs are accessible via the More list.
- On Android all 6 tabs are visible in the tab bar directly.
- On iPad: The More tab only appears when the window is resized to a compact width size class. For iOS 18 and older, a Split View must be triggered to achieve this.
- A toast message
onTabSelectionPrevented: <key>appears whenever a native selection is blocked.
- Launch the app and navigate to Prevent native selection.
- Expected: On Android — six tabs visible in the tab bar. On iOS — four tabs
and a More item visible.The First tab is selected
and displays
preventNativeSelection: falseunder its name on the screen.
- While on the First tab, tap Toggle preventNativeSelection.
- Expected: The label updates to
preventNativeSelection: true.
- Tap the Second tab item in the tab bar.
- Expected: Second tab is selected normally.
preventNativeSelectionisfalseon Second.
- Tap the First tab item in the tab bar.
- Expected: The tab does not change. A toast appears with
onTabSelectionPrevented: First.
- Tap Select First button (programmatic navigation).
- Expected: Navigation switches to the First tab normally — programmatic
navigation is not blocked by
preventNativeSelection.
- While on the First tab (with
preventNativeSelection: true), tap Toggle preventNativeSelection.
- Expected: The label updates back to
preventNativeSelection: false.
- Navigate to a different tab and then tap the First tab item in the tab bar.
- Expected: Tab switches normally. No toast appears.
- Navigate to the Third tab and tap Toggle preventNativeSelection.
- Expected: Third tab label shows
preventNativeSelection: true.
- Navigate to the Fourth tab and tap Toggle preventNativeSelection.
- Expected: Fourth tab label shows
preventNativeSelection: true.
- Tap the Third tab item in the tab bar.
- Expected: Tab does not switch. Toast appears with
onTabSelectionPrevented: Third.
- Navigate to the First tab and confirm its
preventNativeSelectionis stillfalse.
- Expected: First tab label shows
preventNativeSelection: false. Tapping it from another tab works normally.
- Navigate to the Fifth tab via the Select Fifth button (programmatic).
- Expected: Fifth tab is displayed normally.
- Tap Toggle preventNativeSelection on the Fifth tab.
- Expected: Label updates to
preventNativeSelection: true.
- Tap Select Sixth, then tap Toggle preventNativeSelection.
- Expected: Label updates to
preventNativeSelection: true.
- Tap Select First, then tap More in the tab bar.
- Expected: Navigation to Sixth is blocked. Toast appears with
onTabSelectionPrevented: Sixth. The More list is displayed.
- Tap Fifth in the More list.
- Expected: Navigation to Fifth is blocked. Toast appears with
onTabSelectionPrevented: Fifth. The More list remains displayed.
- Tap Fourth tab and navigate to Fifth via Select Fifth, tap Toggle preventNativeSelection to disable it.
- Expected: Fifth tab label shows
preventNativeSelection: false.
- Navigate away, then tap More.
- Expected: Navigation to Fifth proceeds normally. No toast appears.
- Tap More again and tap Fifth from list.
- Expected: Navigation to Fifth proceeds normally. No toast appears.
- Resize app to full screen width.
- Expected: More tab disappear. Fifth tab is selected.
- Open Sidebar and select Sixth from the list.
- Expected: Navigation to Sixth is blocked. Toast appears with
onTabSelectionPrevented: Sixth. The Fifth tab is selected and its content remains displayed.
- Open Sidebar.
- Expected: Fifth tab is selected.
- Tap Second from Sidebar list and tap Toggle preventNativeSelection.
- Expected: Label updates to
preventNativeSelection: true.
- Tap Select Sixth and tap Toggle preventNativeSelection.
- Expected: Label updates to
preventNativeSelection: false.
- Tap Fourth and then from the Sidebar tap Sixth.
- Expected: Tab switches normally. No toast appears.
- Tap Second from tab bar.
- Expected: Navigation to Second is blocked. Toast appears with
onTabSelectionPrevented: Second. The Sixth tab is selected and its content remains displayed.