Skip to content

KeyboardAvoidingView shows the keyboard avoiding area even if the keyboard is closed #46942

@QichenZhu

Description

@QichenZhu

Description

In the new architecture, if you open the soft keyboard, unmount KeyboardAvoidingView, close the keyboard, and then remount KeyboardAvoidingView, it still assumes the keyboard is open and displays the keyboard avoiding area.

This issue may happen during navigation because the KeyboardAvoidingView can be unmounted when you navigate away and remounted when you navigate back.

Steps to reproduce

  1. Build the reproducer with New Arch enabled and run it on iOS.

  2. Click Show Keyboard, and ensure the soft keyboard is visible. If not, enable it in the simulator menu: I/O -> Keyboard -> Toggle Software Keyboard.

  3. Click Freeze, Hide Keyboard, Unfreeze buttons in sequence.

Expected result: No blank area under the grey section.

Actual result: A blank area appears under the grey section.

React Native Version

0.75.4

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.5
  CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
  Memory: 11.68 GB / 24.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.15.1
    path: ~/.nvm/versions/node/v20.15.1/bin/node
  Yarn:
    version: 3.6.4
    path: ~/.nvm/versions/node/v20.15.1/bin/yarn
  npm:
    version: 10.7.0
    path: ~/.nvm/versions/node/v20.15.1/bin/npm
  Watchman:
    version: 2024.07.29.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/penguin/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java: Not Found
  Ruby:
    version: 3.1.2
    path: /Users/penguin/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.4
    wanted: 0.75.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

N/A

Reproducer

https://github.com/QichenZhu/reproducer-react-native-keyboard-avoiding-view.git

Screenshots and Videos

373094107-d6765f8b-e297-4fef-ad4d-c443843663e2.mp4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions