'screenOptions:{{tabBarHideonKeyboard: true}} not Working

When I am using custom tab bar through tabBar function tabBarHideOnKeyboard does not work but without tabBar function it works fine, any ideas on how I can make it work using tabBar function as well.



Solution 1:[1]

You'll get the tabBarHideOnKeyboard from the props for the custom tabBar.

tabBar={(props) => {
  return (
    <View>
      {props.state.routes.map((route, index) => {
        // You can replace Pressable and View with anything you like
        return (
          props.descriptors[route.key].options.tabBarHideOnKeyboard && (
            <Pressable>
              <View
                style={{
                  width: 200,
                  height: 200,
                  backgroundColor: "green",
                }}
              />
            </Pressable>
          )
        );
      })}
    </View>
  );

You can read more here

Solution 2:[2]

Add "softwareKeyboardLayoutMode": "pan" in app.json file under "android" key and then restart your expo server with expo start -c

Solution 3:[3]

<Tab.Navigator
  tabBarOptions={{
    showLabel: false,
    keyboardHidesTabBar: true, // use this props to hide bottom tabs when keyboard shown
  }}

the docs says to use tabBarHideOnKeyboard, but not working at all. then i found keyboardHidesTabBar and works like a charm

Solution 4:[4]

I was using my customTab as well. And after huge amount of search, solved the problem with the help of Keyboard event listeners.

This is the best solution, I've found so far.

Here's my solution:

import { useEffect, useState } from "react";
import { Keyboard, Text, TouchableOpacity, View } from "react-native"

export default function TabBar({ state, descriptors, navigation }) {
    // As default it should be visible
    const [visible, setVisible] = useState(true);

    useEffect(() => {
        const showSubscription = Keyboard.addListener("keyboardDidShow", () => {
            //Whenever keyboard did show make it don't visible
            setVisible(false);
        });
        const hideSubscription = Keyboard.addListener("keyboardDidHide", () => {
            setVisible(true);
        });

        return () => {
            showSubscription.remove();
            hideSubscription.remove();
        };
    }, []);

   //Return your whole container like so
   return visible && (
         <View>
             ...
         </View>
         )

tabBarHideOnKeyboard or keyboardHidesTabBar options didn't work for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jted95
Solution 2 localhost_3000
Solution 3 Zacquio
Solution 4