diff --git a/src/app/util/keyboard.ts b/src/app/util/keyboard.ts index 8c1c66725..b1fd3eea6 100644 --- a/src/app/util/keyboard.ts +++ b/src/app/util/keyboard.ts @@ -1,3 +1,4 @@ +import {App} from "@capacitor/app" import {Capacitor} from "@capacitor/core" import {Keyboard} from "@capacitor/keyboard" import {noop} from "@welshman/lib" @@ -13,9 +14,16 @@ export const syncKeyboard = () => { document.body.classList.remove("keyboard-open") }) + // On Android, system-dismissing the IME during pause doesn't fire keyboardWillHide, + // so on resume we force a hide to re-sync native insets and clear our CSS state. + const resumeListener = App.addListener("appStateChange", ({isActive}) => { + if (isActive) Keyboard.hide() + }) + return () => { showListener.then(listener => listener.remove()) hideListener.then(listener => listener.remove()) + resumeListener.then(listener => listener.remove()) document.body.classList.remove("keyboard-open") } }