capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

bug: Input focus will not trigger keyboard on Android

Open peterlindholm opened this issue 5 years ago • 4 comments

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

peterlindholm avatar Jun 17 '20 11:06 peterlindholm

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.

jcesarmobile avatar Jun 17 '20 16:06 jcesarmobile

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.

peterlindholm avatar Jun 18 '20 06:06 peterlindholm

This may be similar to #7753 - will need to look into this.

harveyea30 avatar May 02 '25 15:05 harveyea30

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.

ionitron-bot[bot] avatar May 02 '25 15:05 ionitron-bot[bot]