Skip to content

Comments

fix: Handle enabling interactions for RNSScreenStack that is moved to window#3469

Draft
kmichalikk wants to merge 1 commit intomainfrom
@kmichalikk/gestures-with-pager-view
Draft

fix: Handle enabling interactions for RNSScreenStack that is moved to window#3469
kmichalikk wants to merge 1 commit intomainfrom
@kmichalikk/gestures-with-pager-view

Conversation

@kmichalikk
Copy link
Contributor

Description

This fix handles the case where the whole nested ScreenStack is moved to window with UIPageViewController. The logic worked under the assumption that the nested stack is put inside outer stack's screen, but this is not the case here.

We had a similar case when the hierarchy changed on JS reload. The same fix can be used here by just removing a condition.

Changes

Modified RNSScreenStack.didMoveToWindow

Test code and steps to reproduce

Install react-native-pager-view and paste the following code into App.tsx:

import React, { useState } from 'react';
import PagerView from 'react-native-pager-view';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { Button, ScrollView, Text, View } from 'react-native';
import { NavigationContainer, NavigationIndependentTree, NavigationProp } from '@react-navigation/native';

const OuterStack = createNativeStackNavigator();
const InnerStack = createNativeStackNavigator();

function Screen(props: { navigation: NavigationProp<any> }) {
  const [click, setClick] = useState(false);

  return (<>
    <Button title='click' onPress={() => setClick(c => !c)}/>
    <Button title='push' onPress={() => props.navigation.navigate('inner2')}/>
    { click && <Text>clicked</Text>}
  </>)
}

function Inner() {
    return (<NavigationIndependentTree>
      <PagerView style={{ flex: 1 }} initialPage={0} scrollEnabled={true}>
        <View key="0" style={{ backgroundColor: 'blue' }}>
          <Text>This Works</Text>
        </View>
        <View key="1" style={{ backgroundColor: 'red' }}>
          <NavigationContainer>
              <InnerStack.Navigator>
                <InnerStack.Screen name='inner' component={Screen} options={{ headerBackButtonDisplayMode: 'minimal' }} />
                <InnerStack.Screen name='inner2' component={Screen} options={{ headerBackButtonDisplayMode: 'minimal' }} />
              </InnerStack.Navigator>
          </NavigationContainer>
        </View>
        <View key="2" style={{ backgroundColor: 'red' }}>
          <NavigationContainer>
              <InnerStack.Navigator>
                <InnerStack.Screen name='inner' component={Screen} />
                <InnerStack.Screen name='inner2' component={Screen} />
              </InnerStack.Navigator>
          </NavigationContainer>
        </View>
      </PagerView>
    </NavigationIndependentTree>)
}

export default function App() {
  return (
    <NavigationContainer>
      <OuterStack.Navigator>
        <OuterStack.Screen name='outer' component={Inner} />
      </OuterStack.Navigator>
    </NavigationContainer>
  )
}

@kmichalikk kmichalikk marked this pull request as draft December 10, 2025 14:25
@kmichalikk kmichalikk self-assigned this Dec 10, 2025
@kmichalikk kmichalikk added Type: Bug Something isn't working Area: Native Stack Platform: iOS This issue is specific to iOS labels Dec 10, 2025
@kkafar
Copy link
Member

kkafar commented Dec 16, 2025

What is the state of this PR here? Is it ready for review?

@huats
Copy link

huats commented Feb 17, 2026

I do hope this patch will be merged. Tested on RN 0.83.1 + New Architecture + iOS 26. Confirmed: react-native-screens@4.23.0 with PR #3469 applied manually fixes the freeze when using Stack.Navigator nested inside Material Top Tabs
(UIPageViewController). Before that my only solution was to pin to 4.16

@kkafar
Copy link
Member

kkafar commented Feb 17, 2026

@kmichalikk can you update me what's the status of this PR?

@kmichalikk
Copy link
Contributor Author

This is a potential fix for #3466.
Originally, we hesitated to merge this because it touches core functionalities, so I tagged is as a draft and waited for issue author to respond. There's still no response there (some unrelated issue got solved in the thread), so the PR just sits here.

Since this solves @huats problem we can revisit this now.

@huats
Copy link

huats commented Feb 18, 2026

I'll be happy to test some elements if that can be helpful !

@kmichalikk
Copy link
Contributor Author

@huats could you check if #3631 fixes the problem instead this patch?

This draft here is an old PR that fixes old logic. We're withdrawing from blocking interactions during transition, because we now have a proper fix for some state-related bugs, and we'll probably make it a default some time in the feature, and, if there are no bugs, remove the interaction disabling code entirely.

@huats
Copy link

huats commented Feb 20, 2026

Sorry for the time to get back to you. Yes I can confirm that #3631 also fixes my issue ! So if would be great to have either of one to be merged so that I can avoid to maintain a separe patch in my tree. Thanks for your help !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Native Stack Platform: iOS This issue is specific to iOS Type: Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants