Skip to content

feat(android): add LAST_KNOWN eventMode config option - #78

Open
lincolnthree wants to merge 1 commit into
ionic-team:mainfrom
lincolnthree:fix/android-keyboard-animation-heights
Open

feat(android): add LAST_KNOWN eventMode config option#78
lincolnthree wants to merge 1 commit into
ionic-team:mainfrom
lincolnthree:fix/android-keyboard-animation-heights

Conversation

@lincolnthree

@lincolnthree lincolnthree commented Aug 19, 2026

Copy link
Copy Markdown

Bug Report / Issue

Closes ionic-team/capacitor-plugins#2587

Description

On Android, the @capacitor/keyboard plugin can report inconsistent or incorrect keyboard heights (sometimes smaller than the actual keyboard, or 0) during keyboard animations or when WindowInsets are applied. The events keyboardWillShow and keyboardDidShow may fire with intermediate sizes instead of the final settled keyboard height, causing UI jumps or layout issues, particularly noticeable on newer Android versions (14/15) with edge-to-edge configurations.

This is a root cause of the common "Grey bar above keyboard" issue reported in many other issues (such as ionic-team/capacitor#8525, ionic-team/capacitor#8575, ionic-team/capacitor#8329, and ionic-team/capacitor-plugins#2205).

This PR introduces an eventMode: "LAST_KNOWN" configuration option for Android to smooth out the keyboard animation.

What it does:

  1. Tracks the Highest Known Height: Tracks the knownKeyboardHeight to avoid emitting intermediate sizes during the WindowInsetsAnimationCompat lifecycle (onPrepare, onProgress, onStart, onEnd).
  2. Smooths Event Emission: Only emits WILL_SHOW and DID_SHOW if the height actually changes, falling back to the LAST_KNOWN height instead of transient smaller heights during animation.

This change is backward compatible as the default eventMode remains "DEFAULT".

This adds an eventMode configuration option for Android to smooth out intermediate/jittering keyboard heights that are incorrectly emitted during WindowInsetsAnimation. Setting this to LAST_KNOWN ensures that listeners only receive the true/final keyboard height, resolving layout jump issues on Android 15/edge-to-edge configurations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent Keyboard Height on Android during WindowInsetsAnimation (Proposed Patch)

1 participant