Hide nav when keyboard is open

This commit is contained in:
Jon Staab
2025-11-25 15:30:40 -08:00
parent bfdc69f18c
commit e083719ceb
5 changed files with 40 additions and 2 deletions
+21
View File
@@ -0,0 +1,21 @@
import {Capacitor} from '@capacitor/core'
import {Keyboard} from "@capacitor/keyboard"
import {noop} from '@welshman/lib'
export const syncKeyboard = () => {
if (!Capacitor.isNativePlatform()) return noop
const showListener = Keyboard.addListener("keyboardWillShow", () => {
document.body.classList.add("keyboard-open")
})
const hideListener = Keyboard.addListener("keyboardWillHide", () => {
document.body.classList.remove("keyboard-open")
})
return () => {
showListener.then(listener => listener.remove())
hideListener.then(listener => listener.remove())
document.body.classList.remove("keyboard-open")
}
}