ionic-team / ionic-team/capacitor
[Bug]: Android Keyboard reserves too much space on rapid re-focus after background-tap dismiss (keyboards with suggestion strip), causing double layout jump
- Dominant language
- TypeScript
- Stars
- 16.7k
- Forks
- 1.3k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 10
Description
### Capacitor Version
Latest Dependencies:
@capacitor/cli: 8.5.0
@capacitor/core: 8.5.0
@capacitor/android: 8.5.0
@capacitor/ios: 8.5.0
Installed Dependencies:
@capacitor/cli: 8.5.0
@capacitor/android: 8.5.0
@capacitor/core: 8.5.0
@capacitor/ios: 8.5.0
### Other API Details
```Shell
```
### Platforms Affected
- [ ] iOS
- [x] Android
- [ ] Web
### Current Behavior
When the keyboard is dismissed by tapping the background (input blur) and the same (or another) input is re-focused quickly (within ~1 second), the keyboard initially reserves more vertical space than it actually needs. A few milliseconds later the reserved space corrects itself to the true keyboard height, producing a visible double jump of the webview/layout.
The issue is timing-dependent and only reproducible with a specific dismiss method:
✅ Happens: dismiss via background tap (input blur) → quickly re-focus input
❌ Never happens: dismiss via native back button → re-focus input (any speed)
❌ Never happens: background tap dismiss → wait 1–2 seconds → re-focus input
The issue also appears to depend on the keyboard app — specifically on whether it renders a suggestion strip above the keys:
✅ Reproducible on Gboard (has suggestion strip)
✅ Reproducible on SwiftKey (has suggestion strip)
❌ Not reproducible on a keyboard without a suggestion strip — rapid re-focus resizes correctly out of the box
### Expected Behavior
Re-focusing an input immediately after a blur-based dismiss should resize the layout once, to the correct keyboard height — identical to the behavior after a native-back dismiss or after waiting between taps.
### Project Reproduction
https://github.com/kosserin/android-capacitor-keyboard-issue
### Additional Information
Steps to Reproduce:
- Create a page with a text input and enough empty background area to tap.
- Tap the input → keyboard (e.g. Gboard or SwiftKey) opens normally.
- Tap the background to blur the input → keyboard closes normally. ✅
- Immediately (within ~1s) tap the input again.
Observe: the layout jumps up more than needed, then a few milliseconds later snaps back down to the correct keyboard height → visible double jump.
To confirm the timing dependency, repeat steps 3–4 but wait 1–2 seconds before re-focusing: the keyboard opens with a single, correct resize every time.
To confirm the dismiss-method dependency, dismiss with the native back button instead of a background tap: rapid re-focus works correctly every time.
To confirm the keyboard dependency, switch to a keyboard app without a suggestion strip and repeat the rapid re-focus sequence: the layout resizes correctly in a single step every time.
Link of reproduction: https://jumpshare.com/share/Ous2mkGIQQdDbATIVV9g
Reproduced on Android 16, edge to edge support
Contributor guide
Research direction
Start with the linked reproduction project and reproduce the rapid background-tap dismiss and re-focus sequence on Android 16 using Gboard or SwiftKey. Compare it with native-back dismissal, delayed re-focus, and a keyboard without a suggestion strip; the fix is done when rapid re-focus produces one correctly sized layout update without a double jump.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100