Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24181] Parity: ListItem properties set to undefined/null have inconsistent results on iOS and Android

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2017-05-17T22:09:59.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.1.0
ComponentsTiAPI
Labelsparity
ReporterShawn Lan
AssigneeJoshua Quick
Created2016-03-12T02:01:10.000+0000
Updated2017-05-17T22:34:30.000+0000

Description

index.xml
<Alloy>
	<Window class="container">
		<ListView defaultItemTemplate="template">
            <Templates>
                <ItemTemplate name="template" accessoryType="Ti.UI.LIST_ACCESSORY_TYPE_DISCLOSURE" backgroundColor="red">
                    <Label bindId="title" />
                </ItemTemplate>
            </Templates>
			<ListSection id="listsection1" />
		</ListView>
	</Window>
</Alloy>
index.js
$.index.open();

var listitem = {
	properties:{
		accessoryType: undefined,
		backgroundColor:undefined
	},
	title:{text:'List Item Title'}
};
$.listsection1.setItems([listitem]);
On iOS, the properties fall back to the values set in the template. On Android, the properties fall back to the default values. This is inconvenient for cross-platform development.

Comments

  1. Feon Sua Xin Miao 2016-11-29

    SDK 5.5.1.GA, 6.0.0.GA This is reproducible by the following classic app:
       var template = {
       	properties: {
               name: "template",
       		accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_DISCLOSURE,
               backgroundColor: 'red'
       	},
       	childTemplates: [
       	{
       		type: 'Ti.UI.Label',
       		bindId: 'title',
       		properties: {
       			bindId: 'title'
       		}
       	}
       	]
       };
       
       var win = Ti.UI.createWindow({ title: 'Complex Templates' });
       var section = Ti.UI.createListSection();
       var listView = Ti.UI.createListView({
       	sections: [section],
       	templates: { 'template': template },
       	defaultItemTemplate: 'template'
       });
       var item = {
       	properties: {
       		accessoryType: undefined,
       		backgroundColor: undefined
       	},
       	title: {
       		text: "List Item Title"
       	}
       };
       section.setItems([item]);
       win.add(listView);
       win.open();
       
  2. Chee Kiat Ng 2016-11-30

    So the expected result is that android falls back to the values set in the template right?
  3. Frankie Merzadyan 2016-12-09

    master: https://github.com/appcelerator/titanium_mobile/pull/8670 6_1_0: https://github.com/appcelerator/titanium_mobile/pull/9017
  4. Abir Mukherjee 2017-05-09

    FAILED FR with this environment: Node Version: 6.10.1 NPM Version: 3.10.10 Mac OS: 10.12.4 Appc CLI: 6.2.0 Appc CLI NPM: 4.2.9 Titanium SDK versions: 6.1.0, 6.2.0 locally built (on appropriate branch) Appcelerator Studio, build: 4.8.1.201612050850 Xcode 8.3.2 Android device 6.0.1 iOS Device 10.3 On iOS device, the background of the Title is red as expected. On the Android device it is black. Per the ticket, it should be red. I tested the demo code in the PR (classic version) and the Alloy version in the ticket.
  5. Samir Mohammed 2017-05-17

    Verified fix in 6.2.0.v20170517150008 and 6.1.0.v20170517143931. Test and other information can be found at: Master: https://github.com/appcelerator/titanium_mobile/pull/8670 6_1_X: https://github.com/appcelerator/titanium_mobile/pull/9017

JSON Source