Keyboard plugin - replace setWindowInsetsAnimationCallback with setOnApplyWindowInsetsListener#2398
Conversation
I noticed an issue when the number row is enabled in my Gboard. The Keyboard plugin doesn't resize the view properly in this case. The reason is that the number row is added after the keyboard opening lifecycle is finished. Since the Keyboard plugin listens to `setWindowInsetsAnimationCallback` events (onStart and onEnd) to update the view height, it misses this last inset change after the keyboard opening animation is complete. I propose replacing the current listener with `setOnApplyWindowInsetsListener`, which listens to all inset changes, enabling the plugin to properly adjust the view height whenever the keyboard height changes. Here's the link to the issue I commented on: https://github.com/ionic-team/capacitor-plugins/issues/2371
| if (showingKeyboard) { | ||
| keyboardEventListener.onKeyboardEvent(EVENT_KB_WILL_SHOW, Math.round(imeHeight / density)); | ||
| } else { | ||
| keyboardEventListener.onKeyboardEvent(EVENT_KB_WILL_HIDE, 0); |
There was a problem hiding this comment.
Tried this out myself. Thank you so much for fixing this issue. A small bit of feedback. There is no local variable keyboardEventListener, so it should refer to the class one
| if (showingKeyboard) { | |
| keyboardEventListener.onKeyboardEvent(EVENT_KB_WILL_SHOW, Math.round(imeHeight / density)); | |
| } else { | |
| keyboardEventListener.onKeyboardEvent(EVENT_KB_WILL_HIDE, 0); | |
| if (showingKeyboard) { | |
| this.keyboardEventListener.onKeyboardEvent(EVENT_KB_WILL_SHOW, Math.round(imeHeight / density)); | |
| } else { | |
| this.keyboardEventListener.onKeyboardEvent(EVENT_KB_WILL_HIDE, 0); |
There was a problem hiding this comment.
Hi. Thank you for looking into my PR.
The keyboardEventListener variable is actually declared above in line 36. I didn't change anything related to it; my change preserves the way the previous code was using the event listener variable. I only replaced the usage of setWindowInsetsAnimationCallback() with setOnApplyWindowInsetsListener() for the reason I mentioned in the description.
|
Thanks for opening this PR 🙏 As part of our backlog maintenance effort, we’re reviewing older pull requests for compatibility with the current branch structure and latest releases. Details: https://ionic.io/blog/keeping-capacitors-backlog-healthy This PR will need to be applied to the dedicated Keyboard plugin repository: https://github.com/ionic-team/capacitor-keyboard/ |
I noticed an issue with the Keyboard plugin inaccurately resizing the view when the number row is enabled in my Gboard. The Keyboard plugin doesn't resize the view properly in this case. The reason is that the number row is added after the keyboard opening lifecycle is finished. Since the Keyboard plugin listens to
setWindowInsetsAnimationCallbackevents (onStart and onEnd) to update the view height, it misses this last inset change after the keyboard opening animation is complete.I propose replacing the current listener with
setOnApplyWindowInsetsListener, which listens to all inset changes, enabling the plugin to properly adjust the view height whenever the keyboard height changes.Device: Pixel 9 Pro running API level 36
Dependencies:
Gboard number row option: Settings -> System -> Keyboard -> On-screen keyboard -> Gboard -> Preferences -> Number row
Capacitor configs: