Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8637] Android: auto-focuses and shows keyboard for first textfield on Samsung Galaxy Tab on window open or textfield create after window open

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionDuplicate
Resolution Date2018-06-30T02:30:09.000+0000
Affected Version/sRelease 2.0.0, Release 1.8.1
Fix Version/sn/a
ComponentsAndroid
Labelsapi, parity
ReporterJustin Toth
AssigneeJoshua Quick
Created2012-02-14T10:13:26.000+0000
Updated2018-06-30T02:31:02.000+0000

Description

On a Samsung Galaxy Tab running Android 3.2, if you have a textfield in your window, it will auto set focus to it when either the window is opened or when you create the textfield after the window is opened. This is OK for some situations, such as when you have a form and want it to set focus to the first element by default. However, in other cases, such as when you have a TextField hiding off of the screen and then slide it into view when the user presses a button, it becomes an issue as the keyboard slides up for no reason. Note that it does not set focus to the textfield within the Android emulator. Here is code to reproduce, which creates the textfield after opening the window.

var win = Ti.UI.createWindow({ backgroundColor: "#fff" });
win.addEventListener("open", function() {
	var text = Ti.UI.createTextField({ width: 200, height: 60, top: 20, enabled: false, borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED });
	win.add(text);
});
win.open();
And more code, which shows the same behavior when creating the textfield and then opening the window.

var win = Ti.UI.createWindow({ backgroundColor: "#fff" });
var text = Ti.UI.createTextField({ width: 200, height: 60, top: 20, enabled: false, borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED });
win.add(text);
win.open();
Even setting the textfield to enabled: false, it still auto focuses it. At the very least, there should be a property that you can set that will prevent it from auto focusing the textfield. Ideally it should not auto focus the textfield, that way you have the option of focusing it with the textfield.focus(); method yourself.

Comments

  1. Jan Helleman 2012-03-22

    It's not even consistent. I have a tab view that does not auto focus. But when opening another window with a textfield it does auto focus. It's a serious bug that I cannot translate to my clients.
  2. Ivan Skugor 2012-04-09

  3. Justin Toth 2012-04-20

    I no longer see this issue in 2.0.1.GA2, it looks to be fixed...
  4. Dustin Hyde 2012-04-23

    I am still seeing this issue. SDK: 2.0.1.GA2, 2.0.2.v20120418121806 Studio: 2.0.2.201204201120 OS: Snow Leopard Devices Tested: Galaxy Tab 10.1 3.2 Note: Does not occur on Nexus One 2.2.2, Droid3 2.3.4, Galaxy Nexus 4.0.4, or iOS (parity). The keyboard opens (without permission) when the app first runs. All the previous test code and the code below exhibit the bug behavior.
       var win = Ti.UI.createWindow({
       	backgroundColor:'blue',
       	orientationModes:[Ti.UI.PORTRAIT, Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT]
       });
       
       var textField = Ti.UI.createTextField({
       	backgroundColor:'white',
       	value:'TextField',
       	top:'40%',
       	bottom:'40%',
       	left:'10%',
       	right:'10%',
       	textAlign:Ti.UI.TEXT_ALIGNMENT_CENTER
       });
       
       win.add(textField);
       
       var button = Ti.UI.createButton({
       	title:'Open New Window',
       	backgroundColor:'white',
       	top:'10%',
       	left:'10%',
       	right:'10%',
       	height:'20%',
       	textAlign:Ti.UI.TEXT_ALIGNMENT_CENTER
       });
       
       var subWin = Ti.UI.createWindow({
       	backgroundColor:'green'
       });
       
       var subButton = Ti.UI.createButton({
       	title:'Close',
       	top:'40%',
       	bottom:'40%',
       	left:'20%',
       	right:'20%'
       });
       
       button.addEventListener('click', function(){
       	subWin.open();
       });
       
       win.add(button);
       
       subWin.add(subButton);
       
       subButton.addEventListener('click', function(){
       	subWin.close();
       });
       
       win.open();
       
  5. Shameer Jan 2013-03-18

    Device specific
  6. Joshua Quick 2018-06-30

    This issue will be resolved by [TIMOB-24138]

JSON Source