ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.12k stars 1k forks source link

bug: Input focus will not trigger keyboard on Android #3115

Open peterlindholm opened 4 years ago

peterlindholm commented 4 years ago

Bug Report

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:
  @capacitor/cli: 2.2.0
  @capacitor/core: 2.2.0
  @capacitor/android: 2.2.0
  @capacitor/electron: 2.2.0
  @capacitor/ios: 2.2.0

Installed Dependencies:
  @capacitor/electron not installed
  @capacitor/cli 2.2.0
  @capacitor/core 2.2.0
  @capacitor/android 2.2.0
  @capacitor/ios 2.2.0

[success] Android looking great! 👌
  Found 0 Capacitor plugins for ios:
[success] iOS looking great! 👌

Platform(s)

Android

Current Behavior

On input focus the soft keyboard is not shown unless user has interacted with the webview before the focus event.

Expected Behavior

I would expect the soft keyboard to show on input focus. That is how it works on iOS.

On iOS it seems this behavior can be controlled with the KeyboardDisplayRequiresUserAction configuration. But I haven't been able to figure out how to do something similar for Android.

I know I can trigger the keyboard manually using the Capacitor keyboard plugin, but that way the input type (here number) will no be respected and the regular keyboard is shown.

Is this is expected behavior and if so is there anything we can do to override this?

Code Reproduction

Sample application for repro here: https://github.com/peterlindholm/capacitor-keyboard

Other Technical Details

npm --version output: 6.14.5

node --version output: v12.12.0

jcesarmobile commented 4 years ago

I think it was working in the past, at least since this was merged https://github.com/ionic-team/capacitor/pull/2719, but doesn't seem to work anymore. It's not working in cordova apps neither.

But testing in your app, if you first call focus and then use Capacitor.Plugins.Keyboard.show(), it shows the correct number keyboard, so you can do that as workaround.

peterlindholm commented 4 years ago

Thank you for your response.

I was convinced that I didn't get it working for type="number", but just tried again and it does in fact seem to work. We'll be using that as a workaround for now.