Skip to content

useReanimatedKeyboardAnimation animated values are not reset after KeyboardController enable/disable #1416

@pioner92

Description

@pioner92

Describe the bug

When KeyboardController is disabled via setEnabled(false), animated values from useReanimatedKeyboardAnimation stop updating.

If the keyboard has not fully finished closing before the controller is disabled, the hook keeps the last keyboard height value. After enabling the controller again, useReanimatedKeyboardAnimation still returns those stale values even though the keyboard is already fully closed.

This causes the hook state to be out of sync with the real keyboard state.

Code snippet

const keyboardController = useKeyboardController();

keyboardController.setEnabled(false);

I am using useReanimatedKeyboardAnimation, and after disabling the controller, its animated values are no longer updated or reset.

Repo for reproducing

I do not have a reproduction repository yet.

To Reproduce

Steps to reproduce the behavior:

  1. Use useReanimatedKeyboardAnimation
  2. Open the keyboard
  3. Disable KeyboardController before the keyboard fully finishes closing:
    const keyboardController = useKeyboardController();
    keyboardController.setEnabled(false);
  4. Wait until the keyboard is fully closed
  5. Enable KeyboardController again
  6. Check animated values from useReanimatedKeyboardAnimation
  7. Observe that they still contain stale keyboard height / previous values

Expected behavior

When KeyboardController is disabled, animated values inside useReanimatedKeyboardAnimation should be reset, so that after enabling the controller again they are either:

  • 0 when the keyboard is fully closed, or
  • the current actual values that reflect the real keyboard position

The hook should not keep stale values from the previous keyboard state.

Screenshots

Not attached.

Smartphone (please complete the following information):

  • Desktop OS: macOS
  • Device: Google Pixel 8a
  • OS: Android
  • RN version: 0.81.5
  • RN architecture: [old]
  • JS engine: Hermes
  • Library version: 1.19.1

Additional context

The issue happens specifically when the controller is disabled while the keyboard transition is still in progress. In that case, useReanimatedKeyboardAnimation keeps the last known animated values and does not synchronize them with the actual closed keyboard state after re-enabling the controller.

Metadata

Metadata

Assignees

Labels

repro providedIssue contains reproduction repository/code🐛 bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions