Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-28389

Android: Calling TableViewRow.remove does not remove child view that is a Label

    Details

    • Story Points:
      5
    • Sprint:
      2021 Sprint 5, 2021 Sprint 6, 2021 Sprint 10

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                eharris Ewan Harris
                Reviewer:
                Joshua Quick
                Tester:
                Lokesh Choudhary
              • Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration