Skip to content

The library interacts oddly with Android header height in @react-navigation/native-stack #1292

@DragomirAndrei19

Description

@DragomirAndrei19

Describe the bug
On Android, wrapping the app root with <KeyboardProvider> can either unwantedly add or remove padding around the app header, depending on whether edgeToEdgeEnabled is set to true or false in android/gradle.properties.

  1. If edgeToEdgeEnabled=true and <KeyboardProvider> is present, the entire header becomes too small.
  2. If edgeToEdgeEnabled=true and <KeyboardProvider> is present, the entire header becomes too big

CASE 3 issue has also been referenced here: react-navigation/react-navigation#12653 with multiple users confirming it's the interaction with this library.

It's worth noting that simply removing the provider doesn't re-render the app; I had to rebuild it in order to see the changes.

At one point, I had this in my metro logs:

ERROR [Invariant Violation: Tried to register two views with the same name KeyboardControllerView]
ERROR [Invariant Violation: Tried to register two views with the same name KeyboardGestureArea]
ERROR [Invariant Violation: Tried to register two views with the same name OverKeyboardView]
ERROR [Invariant Violation: Tried to register two views with the same name KeyboardBackgroundView]
ERROR [Invariant Violation: Tried to register two views with the same name KeyboardExtender]

CASE 1: edgeToEdgeEnabled=true and <KeyboardProvider/> CASE 2: edgeToEdgeEnabled=true WITHOUT <KeyboardProvider/>
Image Image
CASE 3: edgeToEdgeEnabled=false and <KeyboardProvider/> CASE 4: edgeToEdgeEnabled=false WITHOUT <KeyboardProvider/>
Image Image

Code snippet

import * as React from 'react';
import { View, Text, StatusBar } from 'react-native';

import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { KeyboardProvider } from 'react-native-keyboard-controller';

import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';

/* -------------------- Screens -------------------- */

function HomeScreen() {
  return (
    <SafeAreaView
      style={{
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
      }}
    >
      <Text>Home Screen</Text>
    </SafeAreaView>
  );
}

/* -------------------- Navigation -------------------- */

const Stack = createNativeStackNavigator();

function RootStack() {
  return (
    <Stack.Navigator
      screenOptions={{
        headerTitleAlign: 'center',
      }}
    >
      <Stack.Screen name="Home" component={HomeScreen} />
    </Stack.Navigator>
  );
}

/* -------------------- App -------------------- */

export default function App() {
  return (
    <SafeAreaProvider>
      <GestureHandlerRootView>
        <KeyboardProvider>
          <StatusBar barStyle="dark-content" />
          <NavigationContainer>
            <RootStack />
          </NavigationContainer>
        </KeyboardProvider>
      </GestureHandlerRootView>
    </SafeAreaProvider>
  );
}

To Reproduce
Steps to reproduce the behavior:

  1. Simply paste the above code in App.tsx

Expected behavior
Padding should remain the same (CASE 2 & CASE 4)

Smartphone/Libraries/Development environment

Library version: 1.20.7

System:
OS: macOS 14.6.1
CPU: (8) arm64 Apple M1 Pro
Memory: 101.95 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 25.2.1
path: /opt/homebrew/bin/node
Yarn:
version: 1.22.19
path: /usr/local/bin/yarn
npm:
version: 11.7.0
path: /opt/homebrew/bin/npm
Watchman:
version: 2025.04.28.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.2
- iOS 18.2
- macOS 15.2
- tvOS 18.2
- visionOS 2.2
- watchOS 11.2
Android SDK: Not Found
IDEs:
Android Studio: 2025.2 AI-252.25557.131.2521.14432022
Xcode:
version: 16.2/16C5032a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 21.0.8
path: /usr/bin/javac
Ruby:
version: 3.2.10
path: /opt/homebrew/opt/ruby@3.2/bin/ruby
npmPackages:

"@react-native-community/cli":
installed: 20.1.1
wanted: ^20.1.1
react:
installed: 19.2.4
wanted: ^19.2.4
react-native:
installed: 0.83.1
wanted: 0.83.1
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true

TemplateApp@0.0.1 /Users/Andrei/Desktop/React_Work/TemplateApp
├── @babel/core@7.28.6
├── @babel/preset-env@7.28.6
├── @babel/runtime@7.28.6
├── @react-native-community/cli-platform-android@20.1.1
├── @react-native-community/cli-platform-ios@20.1.1
├── @react-native-community/cli@20.1.1
├── @react-native/babel-preset@0.83.1
├── @react-native/eslint-config@0.83.1
├── @react-native/metro-config@0.83.1
├── @react-native/typescript-config@0.83.1
├── @react-navigation/native-stack@7.11.0
├── @react-navigation/native@7.1.28
├── @types/jest@30.0.0
├── @types/react-test-renderer@19.1.0
├── @types/react@19.2.10
├── eslint@8.57.1
├── jest@30.2.0
├── prettier@3.8.1
├── react-native-gesture-handler@2.30.0
├── react-native-keyboard-controller@1.20.7
├── react-native-reanimated@4.2.1
├── react-native-safe-area-context@5.6.2
├── react-native-screens@4.20.0
├── react-native-worklets@0.7.2
├── react-native@0.83.1
├── react-test-renderer@19.2.4
├── react@19.2.4
└── typescript@5.9.3

Metadata

Metadata

Assignees

Labels

🐛 bugSomething isn't working🔥 AttentionAn issue, that requires attention (disturbs many users/has many reactions)🤖 androidAndroid specific

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions