Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't hide header with headerShown with some specific device #294

Open
3 tasks done
r0b0t3d opened this issue Feb 7, 2025 · 8 comments
Open
3 tasks done

Couldn't hide header with headerShown with some specific device #294

r0b0t3d opened this issue Feb 7, 2025 · 8 comments
Labels

Comments

@r0b0t3d
Copy link

r0b0t3d commented Feb 7, 2025

Before submitting a new issue

  • I tested using the latest version of the library, as the bug might be already fixed.
  • I tested using a supported version of react native.
  • I checked for possible duplicate issues, with possible answers.

Bug summary

Code

<Tab.Navigator
  tabBar={(props: any) => <BottomTabs {...props} />}
  screenOptions={{
    headerShown: false,
  }}
>

Result

  • iPhone 7Plus (physical device): ios 15.8.3 (the one got issue)
7plus1 7plus2
  • iPhone 16 Pro Max (emulator): ios 18.2 (working fine)
7plus2 7plus2

Library version

0.8.6

Environment info

npx react-native info
info Fetching system and libraries information...
System:
  OS: macOS 15.3
  CPU: (10) arm64 Apple M4
  Memory: 146.67 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.20.5
    path: ~/.nvm/versions/node/v18.20.5/bin/node
  Yarn:
    version: 3.6.4
    path: ~/.nvm/versions/node/v18.20.5/bin/yarn
  npm:
    version: 10.8.2
    path: ~/.nvm/versions/node/v18.20.5/bin/npm
  Watchman:
    version: 2024.12.02.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/tuanluong/.rvm/gems/ruby-3.3.1/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK:
    API Levels:
      - "34"
      - "35"
    Build Tools:
      - 28.0.3
      - 29.0.2
      - 29.0.3
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 32.0.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-34 | Google Play ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 23.0.1
    path: /Users/tuanluong/.sdkman/candidates/java/current/bin/javac
  Ruby:
    version: 3.3.1
    path: /Users/tuanluong/.rvm/rubies/ruby-3.3.1/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.77.0
    wanted: 0.77.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Steps to reproduce

Just add tab navigator with custom tabBar and headerShown is false

Reproducible sample code

<Tab.Navigator
  tabBar={(props: any) => <BottomTabs {...props} />}
  screenOptions={{
    headerShown: false,
  }}
>
@r0b0t3d r0b0t3d added the bug Something isn't working label Feb 7, 2025
@okwasniewski
Copy link
Collaborator

Hey,

This library doesn't (yet) support headers. So it's most likely that the issue comes from somewhere else.

@r0b0t3d
Copy link
Author

r0b0t3d commented Feb 7, 2025

@okwasniewski I did workaround like this

diff --git a/node_modules/react-native-bottom-tabs/ios/TabViewImpl.swift b/node_modules/react-native-bottom-tabs/ios/TabViewImpl.swift
index bde5048..8744767 100644
--- a/node_modules/react-native-bottom-tabs/ios/TabViewImpl.swift
+++ b/node_modules/react-native-bottom-tabs/ios/TabViewImpl.swift
@@ -47,6 +47,7 @@ struct TabViewImpl: View {
 #if os(macOS)
       tabBar = tabController
 #else
+      tabController.navigationController?.setNavigationBarHidden(true, animated: false)
       tabBar = tabController.tabBar
       if (!props.tabBarHidden) {
         onTabBarMeasured(

@okwasniewski
Copy link
Collaborator

This seems like it's related to your project specifically. It looks like your screen is wrapped with a navigation controller that sets it. Maybe it's a NativeStack from React native screens that's causing this?

tabController.navigationController?.setNavigationBarHidden(true, animated: false) This line calls to a navigation controller (provided in most cases by React Native screens) and sets the navigation bar hidden to true. Most likely you can achieve the same thing in JS by setting headerShown: false on your navigation stack wrapping tabs.

@r0b0t3d
Copy link
Author

r0b0t3d commented Feb 8, 2025

@okwasniewski I did set headerShown: false already. The issue never happen with @react-navigation/bottom-tabs. But happened when I use this library

@okwasniewski
Copy link
Collaborator

Can you provide a reproduction where this issue happens outside of your app in an isolated environment?

@alizahid
Copy link

I think there is definitely something weird going on. I'm using bottom-tabs and it does add something extra.

Take a look at this video https://imgur.com/a/kPC9W2l

My root navigator is bottom-tabs with stack navigators inside. The stack navigator (expo router) has a custom header. The header has a BlurView (expo-blur) which doesn't render properly on the first render. If I disable blur and turn it back on, on the next render, it starts working properly. Also works if I change some properties or styles on the BlurView, forcing it to rerender.

In the second part of the video, I navigate to _sitemap and there's a More link to go back to somewhere (bottom-tabs root, maybe?) which has a bunch of stuff.

In the third part of the video, I replace <Tabs> with <Slot> from expo-router and navigate to _sitemap again and that extra stuff goes away. My header starts working properly as well.

GitHub repo in case you wanna look at what's up.

If you want, I can try creating an empty app with a similar structure as mine to help you reproduce?

@emzet93
Copy link

emzet93 commented Feb 18, 2025

Actually I face exactly the same issue on iPhone SE (first one) on iOS 15.
It's indeed nested inside native stack, but with @react-navigation/bottom-tabs all is working as expected and no header is shown.
Parent stack has headerShown set to false. If it's true, it shows header as expected, but when set to false, it shows just header title in floating, absolute way, like at OP's screenshots 🤔

EDIT:
Setting headerTitle: '' on parent stack solves the issue, but seems like a huge hack and I'm not yet sure if it doesn't cause other issues.

EDIT 2:
It actually does - area below this invisible header is not touchable unfortunately.

I can also try to setup repro with similar nav structure if it helps debugging.

@okwasniewski
Copy link
Collaborator

@emzet93 Thanks for looking into this. Repro would be very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants