feat(android): add LAST_KNOWN eventMode config option - #78
Open
lincolnthree wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug Report / Issue
Closes ionic-team/capacitor-plugins#2587
Description
On Android, the
@capacitor/keyboardplugin can report inconsistent or incorrect keyboard heights (sometimes smaller than the actual keyboard, or0) during keyboard animations or whenWindowInsetsare applied. The eventskeyboardWillShowandkeyboardDidShowmay 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:
knownKeyboardHeightto avoid emitting intermediate sizes during theWindowInsetsAnimationCompatlifecycle (onPrepare,onProgress,onStart,onEnd).WILL_SHOWandDID_SHOWif the height actually changes, falling back to theLAST_KNOWNheight instead of transient smaller heights during animation.This change is backward compatible as the default
eventModeremains"DEFAULT".