Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13002] Android: HTML textfields inside webview do not open keyboard

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-02-06T19:33:07.000+0000
Affected Version/sRelease 3.0.0, Release 3.0.2
Fix Version/s2014 Sprint 03, 2014 Sprint 03 API, Release 3.2.3, Release 3.3.0
ComponentsAndroid
Labelsmodule_textfield, qe-closed-3.2.3, qe-testadded, supportTeam, triage
ReporterBetty Tran
AssigneePing Wang
Created2013-03-08T15:42:16.000+0000
Updated2014-04-18T23:47:11.000+0000

Description

Description

When we open a html page that contains textfields inside a webview, clicking on the textfields do not open the soft keyboard in some Android OS versions (tested on 2.3.5).

Code to Reproduce

app.js
var win = Ti.UI.createWindow();

var web = Ti.UI.createWebView({
	height: Ti.UI.FILL,
	width: Ti.UI.FILL,
	url: 'textfield.html'
});

win.add(web);

win.open();
textfield.html
<html>
	<head>
		<title>Test for textfields</title>
	</head>
	<body>
		<form>
                 First name: <input type="text" name="firstname"><br>
                 Last name: <input type="text" name="lastname">
                </form>
	</body>
</html>

Workaround

It seems to work if we set the softKeyboardOnFocus property on the webview to either Titanium.UI.Android.SOFT_KEYBOARD_HIDE_ON_FOCUS, or Titanium.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS and then do web.focus().

Comments

  1. Shameer Jan 2013-03-13

    The problem does not exist with android 4.0.4(titanium sdk 3.0.2 and 3.1.0) and works fine on iphone emulator tested on Titanium Studio, build: 3.0.2.201302191606 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 Device: Samsung galaxy s duos Android version: 4.0.4 Android Emulator: Android SDK version: 2.2 iOS iPhone Simulator: iOS SDK version: 6.0
  2. Eduardo Gomez 2013-10-14

    Work around did not work. The keyboard occasionally did not pop up when we tapped into the input field. Where occasionally means "1 out of 3 attempts". Developer could replicate on Android 2.3.5 device (including me was Droid Razr 2.3.5 w/ TiSDK 3.1.3.GA). Their kindle fire version is also affected by this bug. Whenever the keyboard pop up you can see similar logs, I.E.

    First attempt (keyboard did pop up):

       10-14 14:43:38.453: D/LatinKeyboard(708): updateF1Key-mIsAlphaKeyboard: true ,mHasVoiceButton: true
       10-14 14:43:38.453: D/LatinKeyboard(708): updateF1Key-mIsAlphaKeyboard: true ,mHasVoiceButton: true
       10-14 14:43:38.453: D/LatinKeyboard(708): updateF1Key-mIsAlphaKeyboard: true ,mHasVoiceButton: true
       10-14 14:43:38.460: D/LatinKeyboard(708): updateF1Key-mIsAlphaKeyboard: true ,mHasVoiceButton: true
       10-14 14:43:38.476: D/LatinKeyboard(708): updateF1Key-mIsAlphaKeyboard: true ,mHasVoiceButton: true
       10-14 14:43:38.484: D/LatinKeyboard(708): updateF1Key-mIsAlphaKeyboard: true ,mHasVoiceButton: true
       10-14 14:43:38.507: I/gralloc(514): Allocated 0x6f482e65 size 1665230189
       10-14 14:43:38.562: D/dalvikvm(708): GC_EXTERNAL_ALLOC freed 77K, 32% free 4973K/7303K, external 3647K/3775K, paused 40ms
       10-14 14:43:38.593: I/gralloc(514): Allocated 0x660072 size 6488161
       

    Second attempt (keyboard did pop up):

       10-14 14:44:16.898: D/LatinKeyboard(708): updateF1Key-mIsAlphaKeyboard: true ,mHasVoiceButton: true
       10-14 14:44:16.937: D/LatinKeyboard(708): updateF1Key-mIsAlphaKeyboard: true ,mHasVoiceButton: true
       10-14 14:44:16.953: I/gralloc(514): Allocated 0x660072 size 6488161
       10-14 14:44:16.992: I/gralloc(514): Allocated 0x660072 size 6488161
       10-14 14:44:18.976: D/dalvikvm(2625): GC_CONCURRENT freed 970K, 44% free 4008K/7111K, external 4234K/4816K, paused 6ms+2ms
       10-14 14:44:21.960: D/dalvikvm(2005): GC_EXPLICIT freed 578K, 45% free 3316K/6023K, external 2357K/2773K, paused 70ms
       

    Third attempt (keyboard did not pop up):

    Whenever the keyboard fails and textFields can't gain focus there are not significative logs to narrow down the issue.
       10-14 14:45:05.351: D/dalvikvm(888): GC_EXPLICIT freed 809K, 50% free 4476K/8839K, external 7304K/8263K, paused 72ms
       

    Snippet code

    app.js

       var win = Ti.UI.createWindow();
        
       var web = Ti.UI.createWebView({
           height: Ti.UI.FILL,
           width: Ti.UI.FILL,
           //url: 'textfield.html'
           url: 'test.html'
       });
        
       win.add(web);
        
       win.open();
       

    test.html

       <!doctype html>
       <html>
       	<head>
       		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
       		<!--
       		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
       		-->
       		<meta name="viewport" content="width=device-width, user-scalable=no" />
       	</head>
       	<body>
       		<input name="yyy" id="yyy"placeholder="yyy" value="yyy" type="text"/>
       	</body>
       </html>
       

    Steps to replicate

    1) Launch sample posted originally or use above. 2) Tap a TiUITextField (it may or not open keyboard). 3) Close app via Back button - please repeat steps multiple times.

    Additional details

    As proposed by the Android docs, tag changes does not seem to come into play when setting html attributes: {quote} "You can define multiple viewport properties in the tag's content attribute." {quote} - http://developer.android.com/guide/webapps/targeting.html
  3. Ping Wang 2014-01-23

    master PR: https://github.com/appcelerator/titanium_mobile/pull/5251 For FR, please run KS and Anvil to make sure no new regressions. The test case seems only fail on Droid Razr 2.3.5, so we need [~egomez] to help with testing.
  4. Eduardo Gomez 2014-01-30

    Tested and verified ensures popping up the keyboard: Titanium Command-Line Interface, CLI version 3.2.1-beta3 Alloy 1.3.1-beta3 Titanium SDK version 3.3.0.TIMOB-13002 Mac OSX : 10.8.5 Droid Razr 2.3.5
  5. Sabil Rahim 2014-03-24

    3_2_X Backport : https://github.com/appcelerator/titanium_mobile/pull/5508
  6. Priya Agarwal 2014-03-25

    Verified with test Environment: Appc Studio:3.2.3.201403190645 Sdk:3.2.3.v20140324164913 alloy:1.3.1 titanium:3.2.1 titanium-code-processor:1.1.0 Osx: Maverick(10.9.2) Device:LG-P970(V4.0.4),Nexus7(v4.3) HTML textfield inside webView opens Keyboard successfully. Hence closing this issue. New Bugged logged TIMOB-16695(as not working properly with android (v4.4.2)

JSON Source