diff --git a/native/flow-typed/npm/@react-navigation/bottom-tabs_v5.x.x.js b/native/flow-typed/npm/@react-navigation/bottom-tabs_v5.x.x.js --- a/native/flow-typed/npm/@react-navigation/bottom-tabs_v5.x.x.js +++ b/native/flow-typed/npm/@react-navigation/bottom-tabs_v5.x.x.js @@ -1381,6 +1381,7 @@ +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, +gestureVelocityImpact: number, +safeAreaInsets: $Partial, + +keyboardHandlingEnabled: boolean, // Transition ...TransitionPreset, // Header @@ -1471,7 +1472,6 @@ declare type StackNavigationConfig = {| +mode?: 'card' | 'modal', +headerMode?: 'float' | 'screen' | 'none', - +keyboardHandlingEnabled?: boolean, +detachInactiveScreens?: boolean, |}; diff --git a/native/flow-typed/npm/@react-navigation/devtools_v5.x.x.js b/native/flow-typed/npm/@react-navigation/devtools_v5.x.x.js --- a/native/flow-typed/npm/@react-navigation/devtools_v5.x.x.js +++ b/native/flow-typed/npm/@react-navigation/devtools_v5.x.x.js @@ -1381,6 +1381,7 @@ +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, +gestureVelocityImpact: number, +safeAreaInsets: $Partial, + +keyboardHandlingEnabled: boolean, // Transition ...TransitionPreset, // Header @@ -1471,7 +1472,6 @@ declare type StackNavigationConfig = {| +mode?: 'card' | 'modal', +headerMode?: 'float' | 'screen' | 'none', - +keyboardHandlingEnabled?: boolean, +detachInactiveScreens?: boolean, |}; diff --git a/native/flow-typed/npm/@react-navigation/material-top-tabs_v5.x.x.js b/native/flow-typed/npm/@react-navigation/material-top-tabs_v5.x.x.js --- a/native/flow-typed/npm/@react-navigation/material-top-tabs_v5.x.x.js +++ b/native/flow-typed/npm/@react-navigation/material-top-tabs_v5.x.x.js @@ -1381,6 +1381,7 @@ +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, +gestureVelocityImpact: number, +safeAreaInsets: $Partial, + +keyboardHandlingEnabled: boolean, // Transition ...TransitionPreset, // Header @@ -1471,7 +1472,6 @@ declare type StackNavigationConfig = {| +mode?: 'card' | 'modal', +headerMode?: 'float' | 'screen' | 'none', - +keyboardHandlingEnabled?: boolean, +detachInactiveScreens?: boolean, |}; diff --git a/native/flow-typed/npm/@react-navigation/native_v5.x.x.js b/native/flow-typed/npm/@react-navigation/native_v5.x.x.js --- a/native/flow-typed/npm/@react-navigation/native_v5.x.x.js +++ b/native/flow-typed/npm/@react-navigation/native_v5.x.x.js @@ -1381,6 +1381,7 @@ +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, +gestureVelocityImpact: number, +safeAreaInsets: $Partial, + +keyboardHandlingEnabled: boolean, // Transition ...TransitionPreset, // Header @@ -1471,7 +1472,6 @@ declare type StackNavigationConfig = {| +mode?: 'card' | 'modal', +headerMode?: 'float' | 'screen' | 'none', - +keyboardHandlingEnabled?: boolean, +detachInactiveScreens?: boolean, |}; diff --git a/native/flow-typed/npm/@react-navigation/stack_v5.x.x.js b/native/flow-typed/npm/@react-navigation/stack_v5.x.x.js --- a/native/flow-typed/npm/@react-navigation/stack_v5.x.x.js +++ b/native/flow-typed/npm/@react-navigation/stack_v5.x.x.js @@ -1381,6 +1381,7 @@ +gestureResponseDistance: {| vertical?: number, horizontal?: number |}, +gestureVelocityImpact: number, +safeAreaInsets: $Partial, + +keyboardHandlingEnabled: boolean, // Transition ...TransitionPreset, // Header @@ -1471,7 +1472,6 @@ declare type StackNavigationConfig = {| +mode?: 'card' | 'modal', +headerMode?: 'float' | 'screen' | 'none', - +keyboardHandlingEnabled?: boolean, +detachInactiveScreens?: boolean, |}; diff --git a/native/navigation/root-navigator.react.js b/native/navigation/root-navigator.react.js --- a/native/navigation/root-navigator.react.js +++ b/native/navigation/root-navigator.react.js @@ -63,18 +63,31 @@ id, ...rest }: RootNavigatorProps) { + const [keyboardHandlingEnabled, setKeyboardHandlingEnabled] = React.useState( + true, + ); + const mergedScreenOptions = React.useMemo(() => { + if (typeof screenOptions === 'function') { + return input => ({ + ...screenOptions(input), + keyboardHandlingEnabled, + }); + } + return { + ...screenOptions, + keyboardHandlingEnabled, + }; + }, [screenOptions, keyboardHandlingEnabled]); + const { state, descriptors, navigation } = useNavigationBuilder(RootRouter, { id, initialRouteName, children, - screenOptions, + screenOptions: mergedScreenOptions, defaultScreenOptions, screenListeners, }); - const [keyboardHandlingEnabled, setKeyboardHandlingEnabled] = React.useState( - true, - ); const rootNavigationContext = React.useMemo( () => ({ setKeyboardHandlingEnabled }), [setKeyboardHandlingEnabled], @@ -87,7 +100,6 @@ state={state} descriptors={descriptors} navigation={navigation} - keyboardHandlingEnabled={keyboardHandlingEnabled} detachInactiveScreens={Platform.OS !== 'ios'} />