Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7618] Android: Text field loses focus when changing orientation

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Do
Resolution Date2020-01-09T19:50:04.000+0000
Affected Version/sRelease 2.0.0, Release 3.1.0
Fix Version/sn/a
ComponentsAndroid
Labelsparity, reprod
ReporterAllen Yeung
AssigneeMaggie Chen
Created2012-02-10T14:58:44.000+0000
Updated2020-01-09T19:50:04.000+0000

Description

In the following code, if you select a textfield, and rotate the phone to landscape, the textfield loses focus, and a blur event is fired.
var win = Ti.UI.createWindow({
	softInputMode : (Titanium.UI.Android) ? Ti.UI.Android.SOFT_INPUT_ADJUST_PAN : '',
	windowSoftInputMode : (Titanium.UI.Android) ? Ti.UI.Android.SOFT_INPUT_ADJUST_PAN : ''
});

var tf1 = null;

function addRow() {
	var row = Ti.UI.createTableViewRow({
		height : 80,
		//touchEnabled:false
	});
	
	tf1 = Titanium.UI.createTextField({
		color : '#336699',
		width : 250,
		height : 80,
		focusable : true,
		returnKeyType : Titanium.UI.RETURNKEY_DONE,
		//autocapitalization : Titanium.UI.TEXT_AUTOCAPITALIZATION_WORDS,
		autocorrect : false,
		suppressReturn : true,

	});
	
	tf1.addEventListener('focus', function() {
		Ti.API.info('Focus fired');
		alert('Focus fired');
	});

	tf1.addEventListener('blur', function() {
		Ti.API.info('blur fired');
		alert('Blur fired');
	});
	
	row.add(tf1);
	//row.selectionStyle = Ti.UI.iPhone.TableViewCellSelectionStyle.NONE;
	//row.className = 'control';
	return row;
}

// create table view data object
var data = [];

for(var x = 0; x < 10; x++) {
	data[x] = addRow();
}

var tableView = Ti.UI.createTableView({
	data : data,
	//style : Titanium.UI.iPhone.TableViewStyle.GROUPED
});

win.add(tableView);

win.open();
The expected behavior is for the textfield to remain focused after the orientation.

Comments

  1. jithinpv 2013-03-19

    Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 (03/11/13 15:43 0c88429) Titanium SDK version: 3.0.2 (02/07/13 16:46 a4def81) Device: Samsung galaxy s duos Android version: 4.0.4 jithinpv
  2. Lee Morris 2017-06-27

    I am able to reproduce this issue with the following environment; Pixel (7.1) Studio 4.9.0.201705302345 Ti SDK 6.1.1.v20170623141152 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.8.0_131
  3. Maggie Chen 2018-01-03

    PR https://github.com/appcelerator/titanium_mobile/pull/9515
  4. Alan Hutton 2020-01-09

    It has been decided that this issue should be closed as “Won’t do.” This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. If community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.

JSON Source