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
master: https://github.com/appcelerator/titanium_mobile/pull/12558
FR Passed.
merged to master; 10_0_X for 10.0.0 target; and 9_3_X branch.