Skip to content

Re-emit keyboardDidShow on IME height change#56486

Open
alanleedev wants to merge 1 commit intofacebook:mainfrom
alanleedev:export-D101385688
Open

Re-emit keyboardDidShow on IME height change#56486
alanleedev wants to merge 1 commit intofacebook:mainfrom
alanleedev:export-D101385688

Conversation

@alanleedev
Copy link
Copy Markdown
Contributor

Summary:
Follow-up to D100437445, which replaced the legacy height-based IME detector in ReactRootView.CustomGlobalLayoutListener with a visibility-only detector (WindowInsetsCompat.Type.ime()).

The legacy code also re-emitted keyboardDidShow whenever the IME height changed while still visible (e.g., user toggles the emoji panel or predictive bar). Removing that left these JS consumers reading stale endCoordinates:

  • KeyboardAvoidingView — caches _keyboardEvent, no longer resizes on IME height changes.
  • ScrollView — caches _keyboardMetrics; focused TextInput auto-scroll uses stale screenY/height.
  • Keyboard.metrics() — public API returning the cached payload from the last keyboardDidShow.

Fix: track the last reported IME height and re-emit keyboardDidShow when the keyboard is visible AND (it just appeared OR the height changed), restoring pre-D100437445 semantics. The hide branch is gated on mKeyboardIsVisible so it still fires exactly once per cycle.

Changelog: [Android][Fixed] KeyboardAvoidingView and TextInput auto-scroll not responding to IME height changes (e.g., when toggling emoji panel or predictive bar)

Differential Revision: D101385688

Summary:
Follow-up to D100437445, which replaced the legacy height-based IME detector in `ReactRootView.CustomGlobalLayoutListener` with a visibility-only detector (`WindowInsetsCompat.Type.ime()`).

The legacy code also re-emitted `keyboardDidShow` whenever the IME *height* changed while still visible (e.g., user toggles the emoji panel or predictive bar). Removing that left these JS consumers reading stale `endCoordinates`:
- `KeyboardAvoidingView` — caches `_keyboardEvent`, no longer resizes on IME height changes.
- `ScrollView` — caches `_keyboardMetrics`; focused `TextInput` auto-scroll uses stale `screenY`/`height`.
- `Keyboard.metrics()` — public API returning the cached payload from the last `keyboardDidShow`.

Fix: track the last reported IME height and re-emit `keyboardDidShow` when the keyboard is visible AND (it just appeared OR the height changed), restoring pre-D100437445 semantics. The hide branch is gated on `mKeyboardIsVisible` so it still fires exactly once per cycle.

Changelog: [Android][Fixed] KeyboardAvoidingView and TextInput auto-scroll not responding to IME height changes (e.g., when toggling emoji panel or predictive bar)

Differential Revision: D101385688
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 17, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 17, 2026

@alanleedev has exported this pull request. If you are a Meta employee, you can view the originating Diff in D101385688.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant