{ "id": "129502", "key": "TIMOB-16873", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2014-04-23T17:50:57.000+0000", "created": "2014-04-21T16:12:19.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "ListItem", "ListView", "Switch", "ipass1" ], "versions": [ { "id": "15857", "description": "Release 3.2.2", "name": "Release 3.2.2", "archived": false, "released": true, "releaseDate": "2014-03-09" } ], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-08-06T17:37:03.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "When using Switches in ListViews that contain a large enough number of records so that the user must scroll (I'm using 40 in this test), the Switch components are not reused correctly. In the attached test, you can see that tapping the switch in the first row will cause it to change in other rows as those rows are later rendered (and the switch components are reused).\r\n\r\nh3. Steps to reproduce\r\n# Create an app with the following files:\r\n{code:title=index.js}\r\n\r\nvar items = [];\r\nfor(var x=0;x<40;x++){\r\n\titems.push({\r\n\t\ttemplate: \"tpl1\",\r\n\t\tlbl: {\r\n\t\t\ttext: \"Switch #\" + (x+1)\r\n\t\t},\r\n\t\tdone: {\r\n\t\t\titemId: \"sw_\"+x,\r\n\t\t\tvalue: false\r\n\t\t}\r\n\t});\r\n}\r\n$.main.setItems(items);\r\n\r\n$.index.open();\r\n\r\nfunction handleChange(e){\r\n\tconsole.log(JSON.stringify(e,null,2));\r\n}\r\n{code}\r\n{code:title=index.xml}\r\n\r\n\t\r\n\t\t\r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t\r\n\r\n{code}\r\n{code:title=index.tss}\r\n\".container\": {\r\n\ttop: 40,\r\n\tbackgroundColor:\"white\"\r\n}\r\n{code}\r\n# Run the app and click on the first switch in the list\r\n# Scroll down and look at the other switches (need to at least scroll past the last record on the first page)\r\n\r\nh3. Expected Results\r\nOnly the switch that was tapped should change.\r\nh3. Actual Results\r\nOther switch components are changed as well after scrolling.\r\nh3. Additional Info\r\nSometimes, scrolling back to the top will show that the wrong switch is modified (depending on the size of your list).\r\nI've also been able to reproduce this with text fields if they all start out with the same value or and empty string (\"\"). Seems the reuse issue is somehow related to the initial value of the editable component. In this example, all switches start out in the false ( off ) state.", "attachment": [], "flagged": false, "summary": "iOS: Switch Controls in ListViews are not reused correctly", "creator": { "name": "mgumbs", "key": "mgumbs", "displayName": "Mahlon Gumbs", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "mgumbs", "key": "mgumbs", "displayName": "Mahlon Gumbs", "active": true, "timeZone": "America/New_York" }, "environment": "CLI version 3.2.1, Titanium SDK version 3.2.3.Beta and 3.2.2.GA\r\nOperating System\r\n Name = Mac OS X\r\n Version = 10.9.2\r\niOS Simulator (iOS 7.1)", "comment": { "comments": [ { "id": "302121", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Moving this ticket to engineering as I can reproduce this issue with the provided test case. Note that this ticket is similar to TIMOB-13290 but that is on the Table View.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-04-23T04:04:15.000+0000", "updated": "2014-04-23T04:04:15.000+0000" }, { "id": "302184", "author": { "name": "mgumbs", "key": "mgumbs", "displayName": "Mahlon Gumbs", "active": true, "timeZone": "America/New_York" }, "body": "A couple of updates:\r\n# I've verified the issue exists on Android as well (not iOS specific)\r\n# It looks like it's all input components that are affected, not just Ti.UI.Switch (same test case replacing Ti.UI.Switch with Ti.UI.TextField produces the same issue). So maybe the ticket should be renamed to *Input Controls in ListViews are not reused correctly*", "updateAuthor": { "name": "mgumbs", "key": "mgumbs", "displayName": "Mahlon Gumbs", "active": true, "timeZone": "America/New_York" }, "created": "2014-04-23T14:18:50.000+0000", "updated": "2014-04-23T14:18:50.000+0000" }, { "id": "302231", "author": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Resolving issue as invalid.\r\n\r\nAs you an see in this example, the rows _are_ being reused, that's why changing the value on a switch affect others - they're the same row being reused.\r\n\r\nSolution (note that this is the way you would also do it in native) keep track of your changes and update as necessary:\r\n{code}\r\nfunction handleChange(e){\r\n // Get the current \"row\"\r\n var item = e.section.getItemAt(e.itemIndex);\r\n // Update the switch value\r\n item.done.value = e.value;\r\n // Update the section with the new change\r\n e.section.updateItemAt(e.itemIndex, item);\r\n}\r\n{code}", "updateAuthor": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-04-23T17:50:57.000+0000", "updated": "2014-04-23T17:50:57.000+0000" }, { "id": "302429", "author": { "name": "oromero", "key": "oromero", "displayName": "Olga Romero", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Testing the original provided code, I reproduce the issue with:\r\nAppcelerator Studio, build: 3.3.0.201404221437\r\nTitanium SDK, build 3.3.0.v20140422163054\r\nNode.JS Version: v0.10.13\r\nNPM Version: 1.3.2\r\n├── acs@1.0.14\r\n├── alloy@1.4.0-dev\r\n├── node-appc@0.2.0\r\n├── npm@1.3.2\r\n├── titanium@3.3.0-dev\r\n└── titanium-code-processor@1.1.1-beta1\r\nnpm -g ls titanium: /usr/local/lib\r\n└── titanium@3.3.0-dev (git://github.com/appcelerator/titanium.git#93414d143051df4578b7aa42670008e5ef02c422)\r\nXCode Version: 5.1.1\r\nDevice:\r\niPhone5S iOS 7.0\r\n\r\nI can reproduce it with the reported environment as well.", "updateAuthor": { "name": "oromero", "key": "oromero", "displayName": "Olga Romero", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-04-24T18:30:17.000+0000", "updated": "2014-04-24T18:30:17.000+0000" }, { "id": "439930", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing as invalid. If incorrect, please reopen.", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-06T17:37:03.000+0000", "updated": "2018-08-06T17:37:03.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }