Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

[@react-navigation/material-top-tabs][bare-react-app] Pressing on active tab causes the other tabs touch events to freeze #1329

Open
2 of 5 tasks
aprilmintacpineda opened this issue Mar 24, 2022 · 8 comments

Comments

@aprilmintacpineda
Copy link

Current behavior

When I press on currently active tab, the other tabs' touch events will no longer work

import React from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {createMaterialTopTabNavigator} from '@react-navigation/material-top-tabs';
import {Text, View} from 'react-native';

const TabNavigator = createMaterialTopTabNavigator<{
  Tab1: undefined;
  Tab2: undefined;
  Tab3: undefined;
  Tab4: undefined;
}>();

const Container: React.FunctionComponent = ({children}) => (
  <View
    style={{
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center',
    }}>
    {children}
  </View>
);

const Tab1 = () => (
  <Container>
    <Text>Tab 1</Text>
  </Container>
);

const Tab2 = () => (
  <Container>
    <Text>Tab 2</Text>
  </Container>
);

const Tab3 = () => (
  <Container>
    <Text>Tab 3</Text>
  </Container>
);

const Tab4 = () => (
  <Container>
    <Text>Tab 3</Text>
  </Container>
);

const App: React.FunctionComponent = () => {
  return (
    <NavigationContainer>
      <TabNavigator.Navigator
        tabBarPosition="bottom"
        screenOptions={{
          tabBarActiveTintColor: 'blue',
          tabBarInactiveTintColor: 'gray',
          swipeEnabled: true,
          tabBarStyle: {
            shadowColor: '#000',
            shadowOffset: {
              width: 0,
              height: 0,
            },
            shadowOpacity: 0.1,
            shadowRadius: 5,
            elevation: 4,
            backgroundColor: '#fff',
            borderTopWidth: 0,
          },
          tabBarLabelStyle: {
            textTransform: 'capitalize',
          },
          tabBarIndicatorStyle: {
            top: 0,
          },
        }}>
        <TabNavigator.Screen
          name="Tab1"
          component={Tab1}
          options={{
            tabBarLabel: 'Tab 1',
          }}
        />
        <TabNavigator.Screen
          name="Tab2"
          component={Tab2}
          options={{
            tabBarLabel: 'Tab 2',
          }}
        />
        <TabNavigator.Screen
          name="Tab3"
          component={Tab3}
          options={{
            tabBarLabel: 'Tab 3',
          }}
        />
        <TabNavigator.Screen
          name="Tab4"
          component={Tab4}
          options={{
            tabBarLabel: 'Tab 4',
          }}
        />
      </TabNavigator.Navigator>
    </NavigationContainer>
  );
};

export default App;
Screen.Recording.2022-03-12.at.11.23.32.AM.mov

Expected behavior

When I press on the currently active tab, the other tabs' touch events SHOULD STILL work.

Reproduction

https://github.com/aprilmintacpineda/react-navigation-repro-tab-freezes

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Environment

package version
react-native-tab-view ^3.1.1
react-native-pager-view ^5.4.15
react-native ^0.67.3
expo ^44.0.6
node v16.13.0
yarn 1.22.11
@github-actions
Copy link

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • react-native (found: 0.67.3, latest: 0.67.4)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@aprilmintacpineda
Copy link
Author

This comment pointed out that using a lower version of react-native-tab-view fixes the problem, so I opened it here.

@ElicaInc
Copy link

ElicaInc commented Apr 9, 2022

same problem

@mAdutskevich
Copy link

Same problem

1 similar comment
@GeunwonChoi
Copy link

Same problem

@ElicaInc
Copy link

Downgrade to react-native-tab-view@2.16.0 works fine in my settings.

@GeunwonChoi
Copy link

solve article
#1322

@ElicaInc
Copy link

ElicaInc commented Apr 19, 2022

solve article
#1322

GeunwonChoi Thank you!!!
"react-native-tab-view": "^3.1.1" with "react-native-pager-view": "^5.4.15"
works fine!!!
But I prefer 2.16.0 because of its quick re-render feature.

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

No branches or pull requests

4 participants