Skip to content

Conversation

@ish1416
Copy link

@ish1416 ish1416 commented Nov 8, 2025

Description

Fixes incorrect window.innerHeight and visualViewport.height values on Android < 15 devices, which cause UI elements to be partially overlapped by the keyboard when navigation bars are present.

Closes #8181

Problem

On Android < 15 devices with navigation bars (gesture or button navigation), the browser's viewport calculations don't account for the navigation bar height when the keyboard is open. This causes:

  • Modals and dialogs to be positioned too low
  • Bottom UI elements hidden behind keyboard
  • safe-area-inset-bottom always returns 0
  • Inconsistent behavior compared to Android 15+

Solution

Enhanced CapacitorWebView with native viewport correction:

  1. Navigation bar height detection using Android system resources
  2. Viewport override for visualViewport.height on Android < 15
  3. CSS custom properties injection for --safe-area-inset-bottom
  4. Automatic resize events to notify components

Testing

  • ✅ OnePlus 12R (Android 14) - UI no longer overlapped
  • ✅ Samsung S23 (Android 13) - Correct viewport calculations
  • ✅ Pixel 8 (Android 14) - Bottom padding applied correctly
  • ✅ No regression on Android 15+ devices

Breaking Changes

None - maintains full backward compatibility.

- Exclude IME insets from bottom margin calculation in CapacitorWebView
- Add keyboard handling configuration to Android template
- Fixes extra scroll space equal to keyboard height when keyboard closes
- Enhanced edge-to-edge handler for Android 15+ (API 34+)
- Added keyboard visibility detection and auto-scroll to focused inputs
- Proper IME insets handling to prevent input field overlap
- Maintains compatibility with older Android versions
- Fixes keyboard covering bottom inputs in edge-to-edge mode
- Fix incorrect window.innerHeight and visualViewport.height values
- Add navigation bar height detection and viewport correction
- Inject CSS custom properties for safe-area-inset-bottom
- Prevent UI overlap with keyboard on legacy Android devices
- Maintains compatibility with existing edge-to-edge configurations

Fixes ionic-team#8181
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.

[Bug]: Incorrect visualViewport/innerHeight values on Android < 15: UI partially overlapped by keyboard

1 participant