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

Android crashes on changing tab with formSheet opened inside #2379

Closed
alduzy opened this issue Oct 3, 2024 · 1 comment · Fixed by #2416
Closed

Android crashes on changing tab with formSheet opened inside #2379

alduzy opened this issue Oct 3, 2024 · 1 comment · Fixed by #2416
Assignees
Labels
Missing repro This issue need minimum repro scenario NewArch Issues related only to new architecture OldArch Issues related only to old architecture Platform: Android This issue is specific to Android

Comments

@alduzy
Copy link
Member

alduzy commented Oct 3, 2024

Description

Navigating to another tab crashes the app if there's a screen with presentation: 'formSheet' currently opened in a nested stack.

Error: FragmentManager is already executing transactions

Happens on both architectures.

Screen.Recording.2024-10-03.at.11.50.31.mov

Steps to reproduce

reproduction code
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import React from 'react';
import { Button, StyleSheet, Text, View } from 'react-native';

function HomeScreen({ navigation }: { navigation: any }) {
  return (
    <View style={styles.container}>
      <Button
        title="Go to details"
        onPress={() => navigation.navigate('Details')}
      />
    </View>
  );
}

function DetailsScreen({ navigation }: { navigation: any }) {
  const handleChangeTab = () => {
    const history = navigation.getParent().getState().history;
    const isFirstTab = history[history.length - 1].key.includes('First');
    navigation.navigate(isFirstTab ? 'Second' : 'First');
  };
  return (
    <View style={styles.container}>
      <Text>Details</Text>
      <Button title="Dismiss" onPress={navigation.goBack} />
      <Button title="Change Tab" onPress={handleChangeTab} />
    </View>
  );
}

const Tab = createBottomTabNavigator();
const Stack = createNativeStackNavigator();

function InnerStack() {
  return (
    <Stack.Navigator>
      <Stack.Screen name="Home" component={HomeScreen} />
      <Stack.Screen
        name="Details"
        component={DetailsScreen}
        options={{
          presentation: 'formSheet',
          sheetAllowedDetents: [0.5, 1],
          unstable_screenStyle: { backgroundColor: 'white' },
        }}
      />
    </Stack.Navigator>
  );
}

export default function App() {
  return (
    <NavigationContainer>
      <Tab.Navigator screenOptions={{ headerShown: false }}>
        <Tab.Screen name="First" component={InnerStack} />
        <Tab.Screen name="Second" component={InnerStack} />
      </Tab.Navigator>
    </NavigationContainer>
  );
}

const styles = StyleSheet.create({
  container: { justifyContent: 'center', alignItems: 'center' },
});

  1. Open the formSheet in a nested stack
  2. Navigate to another tab without closing the formSheet

Snack or a link to a repository

repro pasted in "Steps to reproduce"

Screens version

4.0.0-beta.3

React Native version

0.75.0-rc.6

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

Android emulator

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added the Missing repro This issue need minimum repro scenario label Oct 3, 2024
Copy link

github-actions bot commented Oct 3, 2024

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@github-actions github-actions bot added the Platform: Android This issue is specific to Android label Oct 3, 2024
@alduzy alduzy added Repro provided A reproduction with a snack or repo is provided OldArch Issues related only to old architecture NewArch Issues related only to new architecture and removed Missing repro This issue need minimum repro scenario labels Oct 3, 2024
@github-actions github-actions bot added Missing repro This issue need minimum repro scenario and removed Repro provided A reproduction with a snack or repo is provided labels Oct 17, 2024
@alduzy alduzy self-assigned this Oct 17, 2024
@kkafar kkafar closed this as completed in 5ff656e Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro This issue need minimum repro scenario NewArch Issues related only to new architecture OldArch Issues related only to old architecture Platform: Android This issue is specific to Android
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant