Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28389] Android: Calling TableViewRow.remove does not remove child view that is a Label

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2021-05-18T18:13:10.000+0000
Affected Version/sRelease 9.3.2
Fix Version/sRelease 10.0.0, Release 9.3.3
ComponentsAndroid
LabelsTableView, android, regression
ReporterEwan Harris
AssigneeGary Mathews
Created2021-03-12T16:22:02.000+0000
Updated2021-05-18T18:13:14.000+0000

Description

Description

When calling remove in the below code, the REQUIRED label is not removed as expected. *Note*: if the child at index 0 is removed then it will be removed correctly, this appears to be specific to when the child is a Label (wrapping that label in a view also appears to work) Workaround: Wrap the Label in a View
var win = Ti.UI.createWindow({
	backgroundColor : 'white'
});

var rowItems = [];

function formRow(options) {
	var pickerRow = Ti.UI.createTableViewRow({
		pickerTitle : options.title,
		backgroundColor : 'white',
		selectedBackgroundColor : '#E8EFF1',
		height : 50,
		id : options.id
	});

	var subView = Ti.UI.createView({
		layout : 'vertical',
		height : Ti.UI.SIZE,
		touchEnabled : false,
		width : "50%",
		left : 0
	});

	subView.add(Ti.UI.createLabel({
		text : options.title,
		left : '3%',
		color : "#41515D",
		horizontalWrap : true,
		height : Ti.UI.SIZE
	}));

	pickerRow.add(subView);

	pickerRow.add(Ti.UI.createLabel({
		text : 'REQUIRED',
		left : '61%',
		color : '#8AA0AE',
		horizontalWrap : true,
		width : "40%",
		height : Ti.UI.SIZE
	}));
	return pickerRow;

}
var vegitables = formRow({
	title : 'Vegitables',
	id : 'Vegitables Type'
});

var fruits = formRow({
	title : 'Fruits',
	id : 'Fruits Type'
});

var deserts = formRow({
	title : 'Desserts',
	id : 'Desserts Type'
});

rowItems.push(vegitables);
rowItems.push(fruits);
rowItems.push(deserts);

var table = Ti.UI.createTableView({
	data : rowItems,
	minRowHeight : 50,
	separatorColor : 'red'
});

table.addEventListener('click', function(e) {
	Ti.API.info('***** e.row.children BEFORE == ' + e.row.children.length);
	if (e.row.children[1]) {
		e.row.remove(e.row.children[1]);
	}
	Ti.API.info('***** e.row.children AFTER == ' + e.row.children.length);
});

win.add(table);
win.open(); 

Steps to reproduce

1. Add the above code to an existing app.js and build for Android 2. Click a row

Actual

REQUIRED label does not get removed

Expected

REQUIRED label should be removed

Comments

  1. Gary Mathews 2021-03-12

    master: https://github.com/appcelerator/titanium_mobile/pull/12558
  2. Lokesh Choudhary 2021-03-15

    FR Passed.
  3. Christopher Williams 2021-03-16

    merged to master; 10_0_X for 10.0.0 target; and 9_3_X branch.

JSON Source