Titanium JIRA Archive
Appcelerator Community (AC)

[AC-323] textField on tableViewRow loses focus on entering value

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2015-11-12T11:45:53.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsStudio
Labelsfocus, tableViewRow, textfield
ReporterMichael Woode
AssigneeShak Hossain
Created2015-08-26T12:32:39.000+0000
Updated2016-03-11T15:52:17.000+0000

Description

When a textfield has no height property (or property is set as Ti.UI.SIZE) and is placed on a tableViewRow, it loses focus as soon as you start typing, the first character entered is displayed, but after that the field loses focus (without the blur event beeing fired) and no more characters can be entered without focusing the textfield again. This happens both on iOS Simulator (8.4) and on actual device. See example code below. I have tested this with Ti SDK 4.0.0.GA, 4.1.0 GA and 4.2.0.v20150812202823 (textfield loses focus after first char entered), and on Ti SDK 3.5.1.GA it works as expected (no problem). Temporary fix/workaround: Always set height of textfields (which can be troublesome on multiple platforms and on textfields with different font sizes).
var tabGroup = Ti.UI.createTabGroup();

//create app tabs
var win1 = Ti.UI.createWindow({
	title: 'Win1',
	backgroundColor: 'white'
});

var win2 = Ti.UI.createWindow({
	title: 'Win2',
	backgroundColor: 'white'
});

var tab1 = Ti.UI.createTab({
	title: win1.title,
	window: win1
});

var tab2 = Ti.UI.createTab({
	title: win2.title,
	window: win2
});

tabGroup.addTab(tab1);
tabGroup.addTab(tab2);

var theTableView = Ti.UI.createTableView({
	top: 0,
	bottom: 0,
	left: 0,
	right: 0,
});
win1.add(theTableView);

var data = [];
var row = Ti.UI.createTableViewRow({
	height: 64
});

var txtF = Ti.UI.createTextField({
	left: 15,
	right: 15,
	//XXX uncomment the "height"-line, and the text field works as expected
	//XXX comment the "height"-line and the text field loses focus on value beeing entered into text field
	//height: 40,
	hintText: 'theHintText',
	keyboardType: Ti.UI.KEYBOARD_DEFAULT,
	returnKeyType: Ti.UI.RETURNKEY_NEXT,
	borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED
});
row.add(txtF);

txtF.addEventListener('blur', function(e) {
	alert('blur!');
});
txtF.addEventListener('focus', function(e) {
	Ti.API.info('focus!');
});

data.push(row);

theTableView.setData(data);

tabGroup.open();

Comments

  1. Sharif AbuDarda 2015-11-12

    Hello, The issue is resolved in latest SDK 5.0.2.GA. Thanks.
  2. Andrea Vitale 2016-03-11

    This error is present with Ti SDK 5.2.0.GA. I haven't set the height property and the TextField lose its focus after the first insertion. I set the height property to Ti.UI.FILL and now its working.

JSON Source