Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16217] Android: Textfield loses focus and tableView scrolls to top when entering text into textfield and pickers are part of tableViewRows

GitHub Issuen/a
TypeBug
PriorityLow
StatusReopened
ResolutionUnresolved
Affected Version/sRelease 3.2.0
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, pickers, tableView, tableViewRow, textfield
ReporterDa'oud Rashid
AssigneeUnknown
Created2012-04-20T03:55:52.000+0000
Updated2018-02-28T20:04:09.000+0000

Description

When pickers are present in other tableViewRows, an attempt to enter text into a textField results in one character being entered into the field just before the textField loses focus and the tableView scrolls to its top. Without pickers present in other rows, the behavior is as expected and the user can continue to enter text. Sample code:
var win =Ti.UI.createWindow({backgroundColor:'#fff'});

var captions = [];
var fields = [];
var rows = [];
var pickerRows = [];

for (var i = 0, ii=20; i<ii; i++){
	if(i%2==0){
		fields[i] = Ti.UI.createTextField({
			value:'field ' + i + ' contents',
			width:200,
			height:60,
			rowIndex:i
		});
	} else {
		fields[i] = Ti.UI.createPicker({
			type: Titanium.UI.PICKER_TYPE_PLAIN,
			selectionIndicator:true,
			width:200
		});

		if(i%5 == 0){
			fields[i].type = Titanium.UI.PICKER_TYPE_DATE;
		} else {
			for (var x = 0, xx = i; x<xx; x++){
				pickerRows[x] = Ti.UI.createPickerRow({
					title:'row ' + x,
					value:x
				});
			}
			fields[i].add(pickerRows);		
		}
	}

	captions[i] = Ti.UI.createLabel({
		text:'This is caption ' + i,
		width:200,
		height:60
	});
	
 	rows[i] = Ti.UI.createTableViewRow({layout:'vertical'});

 	rows[i].add(captions[i]);
 	rows[i].add(fields[i]);
}

var tableView = Ti.UI.createTableView(
	{
		data:rows
	}
);

win.add(tableView);

win.open();

Comments

  1. Betty Tran 2012-05-01

  2. Da'oud Rashid 2012-05-02

  3. Betty Tran 2012-05-08

    Hi Da'oud, Did the work-around solve your issue? Regards, Betty
  4. Da'oud Rashid 2012-05-28

    Hi Betty, My apologies for the late reply. It's been a busy couple of weeks. Unfortunately, the work-around does not entirely solve the issue. Text fields are no longer losing focus on text-entry, but the containing table still scrolls to its top. I abandoned this approach and placed all my controls on a scroll view a while ago, but look forward to a fix. Again, apologies for the late reply. Kind regards, Da'oud
  5. Betty Tran 2012-05-28

    Hi Da'oud, I just noticed that you were using Titanium SDK 2.0.2.201204191742. I would recommend using the latest official release of the SDK (2.0.1GA2). Does the bug still occur when you build with 2.0.1GA2? I am unable to reproduce it. Regards, Betty
  6. Betty Tran 2012-07-02

    Closing due to age without a response. Unable to reproduce locally.
  7. Joseph Sachs 2013-04-15

    This Issue is still open. I have just tested with Ti SDK 3.1.0 and a TableView with say 10 TextFields. If you tap into one of the TextFields that is not the first 3, nor the last 3, the TableView scrolls out of view upwards
  8. Ritu Agrawal 2014-01-17

    Moving this ticket to engineering as we can reproduce it with 3.2.0 release. It does not appear to be a duplicate of TIMOB-8332. Putting text fields in a table view row is not considered the best practice but we would let engineering decide the fate of this bug.
  9. Mark Mokryn 2014-04-25

JSON Source