Skip to content

fix(ios): resize webview in sync with the keyboard animation - #85

Open
SaebAmini wants to merge 1 commit into
ionic-team:mainfrom
SaebAmini:fix/ios-keyboard-resize-delay
Open

SaebAmini wants to merge 1 commit into
ionic-team:mainfrom
SaebAmini:fix/ios-keyboard-resize-delay

Conversation

@SaebAmini

@SaebAmini SaebAmini commented Sep 30, 2026 •

Copy link
Copy Markdown

Description

On iOS, the webview (or body / ion-app in body / ionic resize modes) is resized well after the keyboard animation finishes, rather than alongside it. This PR removes the artificial delays so the resize happens in sync with the keyboard:

  • onKeyboardWillShow: resize immediately instead of waiting for UIKeyboardAnimationDurationUserInfoKey + 0.2s. Removes the now-unused duration variable.
  • onKeyboardWillHide: resize immediately instead of after a 0.01s delay.
  • resizeElement: apply the new height inside requestAnimationFrame so the style change lands on the next frame rather than mid-frame, which avoids a visible jump.

This is the same fix as #50 by @aeharding (ported from ionic-team/capacitor-plugins#2233), rebased onto current main. #50 no longer merges cleanly because the iPad / Stage Manager handling and the QuickType bar logic changed the same area of Keyboard.m. The original author is credited as a co-author on the commit. If #50 gets rebased and merged instead, feel free to close this one.

Context

Resolves #19. Supersedes #50.

Because of the delay, content under the keyboard (e.g. a focused input or a chat composer) stays hidden for the whole keyboard animation plus 200ms, and then jumps into place. On hide, the webview background shows through for a moment. Android doesn't do this: it resizes before the animation starts. The delay is more noticeable with the iOS 26 translucent / rounded keyboard, as reported in #50 and ionic-team/capacitor#7992.

Type of changes

  • Fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Refactor (cosmetic changes)
  • Breaking change (change that would cause existing functionality to not work as expected)

Platforms affected

  • Android
  • iOS
  • Web

Tests

We've shipped this exact change as a patch-package patch in the production releases of our Capacitor 8 app since July 2026, first on @capacitor/keyboard 8.0.3 and now on 8.0.5, using resize: 'ionic'. With the patch, the resize follows the keyboard animation, and we haven't seen any regressions. The app builds for iOS with the patched plugin.

Co-authored-by: aeharding <2166114+aeharding@users.noreply.github.com>
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.

Keyboard resize is slow in iOS

1 participant