ionic-team / capacitor-plugins

Official plugins for Capacitor ⚡️
518 stars 584 forks source link

Keyboard height is inconsistent #2205

Open TheotimeColin opened 1 week ago

TheotimeColin commented 1 week ago

Bug Report

Plugin(s)

@capacitor/keyboard: 6.0.0

Capacitor Version

Latest Dependencies:
  @capacitor/cli: 6.1.2
  @capacitor/core: 6.1.2
  @capacitor/android: 6.1.2
  @capacitor/ios: 6.1.2

Installed Dependencies:
  @capacitor/cli: 6.1.2
  @capacitor/core: 6.0.0
  @capacitor/ios: 6.1.2
  @capacitor/android: 6.1.2

Platform(s)

Android 14

Current Behavior

keyboardHeight from Keyboard eventListener reports inconsistent values. When I click on an input, the height can be correct, much inferior to the actual height or 0. It seems be basically random.

This did not happen before (maybe an Android update?). I'm using the default keyboard on a Google Pixel.

Expected Behavior

keyboardHeight returns the correct keyboard height.

Code Reproduction

export const initKeyboard = () => {
  const onShow = (info: KeyboardInfo) => {
    console.log('KHEIGHT : ', info.keyboardHeight)
    // Logs 383 (correct), 48 (incorrect) or 0 (incorrect)

    height.value = info.keyboardHeight
  }

  if (Capacitor.isPluginAvailable('Keyboard') && Capacitor.isNativePlatform()) {
    Keyboard.addListener('keyboardWillShow', info => onShow(info))
    Keyboard.addListener('keyboardDidShow', info => onShow(info))
  }

  return { onShow, onHide }
}
Ionitron commented 22 hours ago

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.

Please see the Contributing Guide for how to create a Sample App.

Thanks! Ionitron 💙