KeyboardAvoidingView Leaves Extra Bottom Padding After Keyboard Closes
Personne n'a encore pris cette issue.
- Langage dominant
- C++
- Étoiles
- 127k
- Forks
- 25.3k
- Merge moyen
- 1 j 23 h
- PR mergées (30 j)
- 4
Description
Description
Description
When using KeyboardAvoidingView with behavior="height" on Android in combination with SafeAreaView and useSafeAreaInsets(), remains even after the keyboard closes, leaving an unexpected gap at the bottom of the screen. This issue is more visible on Android devices without soft navigation buttons.
This behavior is inconsistent with iOS, where the padding collapses as expected.
Expected Behavior
When the keyboard closes, the layout should return to its original state, removing any bottom padding unless explicitly added by the developer.
Actual Behavior
After the keyboard closes on Android, an extra bottom padding remains on the screen, pushing up content unnecessarily.
Removing paddingBottom: insets.bottom fixes it, but this breaks devices with safe area (iOS or gesture nav Android) where insets are needed.
Steps to reproduce
Steps To Reproduce
- Create a SafeAreaView wrapping a KeyboardAvoidingView (behavior="height").
- Inside, render a FlatList and an input box pinned to the bottom.
- Open keyboard → input shifts correctly.
- Close keyboard → padding remains, leaving gap at bottom.
<SafeAreaView style={{flex: 1}}> <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} style={{ flex: 1, paddingTop: insets.top, }}> <View style={[ {flex: 1}, theme == 'dark' ? {backgroundColor: AppTheme.dark.screenBackground} : {backgroundColor: AppTheme.light.screenBackground}, ]}> </View> </KeyboardAvoidingView> </SafeAreaView>
React Native Version
0.78.0
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
OS: macOS 15.5
CPU: (8) arm64 Apple M2
Memory: 151.19 MB / 8.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.14.0
path: ~/.nvm/versions/node/v20.14.0/bin/node
Yarn:
version: 4.8.1
path: ~/.nvm/versions/node/v20.14.0/bin/yarn
npm:
version: 10.7.0
path: ~/.nvm/versions/node/v20.14.0/bin/npm
Watchman:
version: 2025.04.28.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /Users/socon/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.5
- iOS 18.5
- macOS 15.5
- tvOS 18.5
- visionOS 2.5
- watchOS 11.5
Android SDK:
API Levels:
- "33"
- "34"
- "35"
Build Tools:
- 30.0.3
- 34.0.0
- 35.0.0
- 35.0.1
- 36.0.0
System Images:
- android-28 | Google ARM64-V8a Play ARM 64 v8a
- android-29 | Google Play ARM 64 v8a
- android-34 | Google Play ARM 64 v8a
- android-35 | Google Play ARM 64 v8a
- android-36 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2024.3 AI-243.26053.27.2432.13536105
Xcode:
version: 16.4/16F6
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.11
path: /usr/bin/javac
Ruby:
version: 3.2.2
path: /Users/socon/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.78.0
wanted: 0.78.0
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
info React Native v0.80.1 is now available (your project is running on v0.78.0).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.80.1
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.78.0&to=0.80.1
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
Stacktrace or Logs
No Crash Happened
MANDATORY Reproducer
NONE
Screenshots and Videos
When Keyboard is Opened it is ok
but when it is closed getting a extra padding below
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par reproduire KeyboardAvoidingView et SafeAreaView comme décrit dans l’issue, en utilisant Android avec behavior="height" et useSafeAreaInsets(). Suivez les changements de layout Android lors de l’ouverture et de la fermeture du clavier. Le travail est terminé lorsque le padding inférieur revient à son état initial après la fermeture du clavier, sans perturber la gestion de la safe area sur les appareils utilisant la navigation gestuelle ni sur iOS.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- android, javascript, react-native
- Domaine
- frontend, mobile
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100