From bd333b958403768c25193c00a0edeb5c6ab2e2b7 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 12 Apr 2026 14:07:52 -0500 Subject: [PATCH] Fix Android WebView resize bugs caused by @capacitor/keyboard Remove resizeOnFullScreen config which caused possiblyResizeChildOfContent() to corrupt CoordinatorLayout height on Android 16 (API 36). Upgrade plugin from 8.0.2 to 8.0.3 which adds a SystemBars guard as additional safety. Platform-gate setAccessoryBarVisible to iOS only (unimplemented on Android). --- capacitor.config.ts | 3 --- package-lock.json | 8 ++++---- package.json | 2 +- src/main.tsx | 10 +++++++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/capacitor.config.ts b/capacitor.config.ts index cf9d0b41..4bec3586 100644 --- a/capacitor.config.ts +++ b/capacitor.config.ts @@ -19,9 +19,6 @@ const config: CapacitorConfig = { scheme: 'Ditto' }, plugins: { - Keyboard: { - resizeOnFullScreen: true, - }, SystemBars: { // Inject --safe-area-inset-* CSS variables on Android to work around // a Chromium bug (<140) where env(safe-area-inset-*) reports 0. diff --git a/package-lock.json b/package-lock.json index 14d721d3..055c2186 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "@capacitor/app": "^8.0.0", "@capacitor/core": "^8.1.0", "@capacitor/filesystem": "^8.1.2", - "@capacitor/keyboard": "^8.0.2", + "@capacitor/keyboard": "^8.0.3", "@capacitor/local-notifications": "^8.0.1", "@capacitor/share": "^8.0.1", "@capgo/capacitor-autofill-save-password": "^8.0.22", @@ -429,9 +429,9 @@ } }, "node_modules/@capacitor/keyboard": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@capacitor/keyboard/-/keyboard-8.0.2.tgz", - "integrity": "sha512-he6xKmTBp5AhVrWJeEi6RYkJ25FjLLdNruBU2wafpITk3Nb7UdzOj96x3K6etFuEj8/rtn9WXBTs1o2XA86A1A==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/@capacitor/keyboard/-/keyboard-8.0.3.tgz", + "integrity": "sha512-27Bv5/2w1Ss2njguBgTS98O0Bb8DRJhAARyzXYib0JlT/n6BrJw/EZ0CokM4C8GFUjFDjJnEKF1Ie01buTMEXQ==", "license": "MIT", "peerDependencies": { "@capacitor/core": ">=8.0.0" diff --git a/package.json b/package.json index a83d0332..22d829b5 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "@capacitor/app": "^8.0.0", "@capacitor/core": "^8.1.0", "@capacitor/filesystem": "^8.1.2", - "@capacitor/keyboard": "^8.0.2", + "@capacitor/keyboard": "^8.0.3", "@capacitor/local-notifications": "^8.0.1", "@capacitor/share": "^8.0.1", "@capgo/capacitor-autofill-save-password": "^8.0.22", diff --git a/src/main.tsx b/src/main.tsx index 6210ef22..c7cfb95a 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -21,12 +21,16 @@ import '@fontsource-variable/inter'; // Uses a MutationObserver so it reacts to all subsequent theme changes // (class changes for builtin themes, style-content changes for custom themes). import { Capacitor, SystemBars, SystemBarsStyle } from '@capacitor/core'; -import { Keyboard } from '@capacitor/keyboard'; import { getBackgroundThemeMode } from '@/lib/colorUtils'; if (Capacitor.isNativePlatform()) { - // Hide the iOS keyboard accessory bar (prev/next/done toolbar above the keyboard) - Keyboard.setAccessoryBarVisible({ isVisible: false }).catch(() => {}); + // Hide the iOS keyboard accessory bar (prev/next/done toolbar above the keyboard). + // Only runs on iOS — setAccessoryBarVisible is unimplemented on Android. + if (Capacitor.getPlatform() === 'ios') { + import('@capacitor/keyboard').then(({ Keyboard }) => { + Keyboard.setAccessoryBarVisible({ isVisible: false }).catch(() => {}); + }).catch(() => {}); + } /** * Sync the native system bar icon style with the active CSS theme. *