{ "id": "171731", "key": "TIMOB-26104", "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": [ { "id": "20238", "description": "", "name": "Release 7.5.0", "archived": false, "released": true, "releaseDate": "2018-11-15" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-10-02T17:54:17.000+0000", "created": "2018-06-04T17:10:17.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "android" ], "versions": [ { "id": "18414", "description": "", "name": "Release 6.2.0", "archived": false, "released": true, "releaseDate": "2017-09-13" } ], "issuelinks": [ { "id": "56708", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "171999", "key": "TIMOB-26255", "fields": { "summary": "iOS: Removing and re-adding \"plain\" picker resets last selection", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "updated": "2018-10-02T17:54:34.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "Starting with Ti 7.x incl. 7.1.1GA on Android the pickerview, when inside a tableview, resets its selected value after events like orientationchange, scroll outside of window and back in or focus on another ui element. \r\n\r\n(works perfectly on ios and used to work perfectly on Ti<=6.x)\r\n\r\nexample code:\r\n\r\n{{\r\n var currentwindow = Ti.UI.createWindow({\r\n });\r\n\r\n var tabledata = [];\r\n\r\n var picker = Ti.UI.createPicker({\r\n top:20\r\n });\r\n\r\n var data = [];\r\n data[0]=Ti.UI.createPickerRow({title:'Bananas'});\r\n data[1]=Ti.UI.createPickerRow({title:'Strawberries'});\r\n data[2]=Ti.UI.createPickerRow({title:'Mangos'});\r\n\r\n picker.add(data);\r\n\r\n var myrow=Ti.UI.createTableViewRow({\r\n \t'height' : '50sp'\r\n });\r\n\r\n myrow.add(picker);\r\n\r\n tabledata.push(myrow);\r\n\r\n\tvar infotableview = Titanium.UI.createTableView({\r\n\t\tdata:tabledata,\r\n\t});\r\n\r\n\tcurrentwindow.add(infotableview);\r\n\r\n //currentwindow.add(picker);\r\n\r\n}}", "attachment": [], "flagged": false, "summary": "Android: Removing and re-adding drop-down picker resets last selection", "creator": { "name": "adegreiff", "key": "adegreiff", "displayName": "Alexander de Greiff ", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "adegreiff", "key": "adegreiff", "displayName": "Alexander de Greiff ", "active": true, "timeZone": "Europe/Berlin" }, "environment": "Android", "closedSprints": [ { "id": 1078, "state": "closed", "name": "2018 Sprint 20 SDK", "startDate": "2018-09-23T16:57:58.349Z", "endDate": "2018-10-07T16:57:00.000Z", "completeDate": "2018-10-07T23:31:40.476Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "438457", "author": { "name": "adegreiff", "key": "adegreiff", "displayName": "Alexander de Greiff ", "active": true, "timeZone": "Europe/Berlin" }, "body": "what will happen with this issue now? do you need more info?", "updateAuthor": { "name": "adegreiff", "key": "adegreiff", "displayName": "Alexander de Greiff ", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-06-17T10:15:30.000+0000", "updated": "2018-06-17T10:15:30.000+0000" }, { "id": "438680", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "I couldn't locate the problem but these _could_ be related to the bug:\r\n\r\nWhen e.g. the orientation changes the picker is created again and it is losing its [old selection value (TiUINativePicker.java)|https://github.com/appcelerator/titanium_mobile/blob/cd91879899ff3629ae78b369e1aa67ca57f48999/android/modules/ui/src/java/ti/modules/titanium/ui/widget/picker/TiUINativePicker.java#L215].\r\n\r\nThese PRs did some changes\r\nhttps://github.com/appcelerator/titanium_mobile/pull/9763/files\r\nhttps://github.com/appcelerator/titanium_mobile/pull/9917/files\r\nhttps://github.com/appcelerator/titanium_mobile/pull/9963/files\r\n\r\nso that would be a good place to start some debugging.\r\nIf I have some more spare time I might have a look again, too", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-06-25T19:31:47.000+0000", "updated": "2018-06-25T19:31:47.000+0000" }, { "id": "439100", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Okay. So, I've confirmed that this is not just an issue with a {{TableView}}. The root issue here is that if you remove the picker from a window and then re-add it, the picker will forget its last selected item and reset to the 1st item. The reason this can happen with a {{TabelView}} too is because Android's native behavior is to remove views that are scrolled off (for performance reasons) and then re-add them when they're scrolled-in. (I'm curious if this would be an issue with {{TabGroups}} as well.)\r\n\r\nHere's how to reproduce this issue without a {{TableView}}...\r\n\r\n*Steps to reproduce:*\r\n# Build and run the below code on Android.\r\n# Tap on the picker.\r\n# Select a picker item other than \"Item 1\".\r\n# Tap on the \"Remove Picker\" button. (This removes it from the window.)\r\n# Tap on the \"Add Picker\" button. (This re-adds it to the window.)\r\n# Notice that the picker's selection has been reset to \"Item 1\".\r\n\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow();\r\nvar picker = Ti.UI.createPicker({ width: \"50%\" });\r\nvar rows = [];\r\nfor (var index = 0; index < 20; index++) {\r\n\trows.push(Ti.UI.createPickerRow({ title: \"Item \" + (index + 1).toString() }));\r\n}\r\npicker.add(rows);\r\nwindow.add(picker);\r\nfunction createButtonText() {\r\n\treturn window.children.includes(picker) ? \"Remove Picker\" : \"Add Picker\";\r\n}\r\nvar button = Ti.UI.createButton({\r\n\ttitle: createButtonText(),\r\n\tbottom: \"20dp\",\r\n});\r\nbutton.addEventListener(\"click\", function(e) {\r\n\tif (window.children.includes(picker)) {\r\n\t\twindow.remove(picker);\r\n\t} else {\r\n\t\twindow.add(picker);\r\n\t}\r\n\tbutton.title = createButtonText();\r\n});\r\nwindow.add(button);\r\nwindow.open();\r\n{code}\r\n\r\n[~ybanev], this is an issue with the picker, not the table view. I think the solution may be to override the picker's {{onAttachedToWindow()}} method and restore the selection there. It's worth a shot.\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-07-10T19:13:23.000+0000", "updated": "2018-07-10T19:13:23.000+0000" }, { "id": "439101", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~adegreiff], is there any reason you're using a {{TableView}} instead of a {{ScrollView}}? I ask because a {{ScrollView}} is significantly simpler and would not have this picker issue.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-07-10T20:33:22.000+0000", "updated": "2018-07-10T20:33:22.000+0000" }, { "id": "439102", "author": { "name": "adegreiff", "key": "adegreiff", "displayName": "Alexander de Greiff ", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~jquick] , we have some enterprise client apps in production where the tableview is the central scaffold and the rows and containing ui objects/properties are coming from the server and interpreted/cached in the client (titanium classic). we are evaluating listviews but they are not as flexible as the layout can change with every row coming from the server.", "updateAuthor": { "name": "adegreiff", "key": "adegreiff", "displayName": "Alexander de Greiff ", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-07-10T20:44:59.000+0000", "updated": "2018-07-10T20:48:46.000+0000" }, { "id": "439104", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I've tested for this issue in Titanium 6.0.2 and have confirmed that the picker \"forgets\" its last selection when detached/re-attached to the window as well. This looks like a Google issue/limitation with the picker that has always existed that we need to work-around. Perhaps Titanium's {{TableView}} has work-around it at one point, but regardless, this issue needs to be resolved in the picker's Java code. We'll look into it. Thanks for reporting this issue.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-07-10T21:10:39.000+0000", "updated": "2018-07-10T21:10:39.000+0000" }, { "id": "439480", "author": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/10211", "updateAuthor": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "created": "2018-07-25T12:41:52.000+0000", "updated": "2018-07-25T12:41:52.000+0000" }, { "id": "441671", "author": { "name": "kmahalingam", "key": "kmahalingam", "displayName": "Keerthi Mahalingam", "active": false, "timeZone": "America/Los_Angeles" }, "body": "FR passed.", "updateAuthor": { "name": "kmahalingam", "key": "kmahalingam", "displayName": "Keerthi Mahalingam", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2018-09-18T23:23:38.000+0000", "updated": "2018-09-18T23:23:38.000+0000" }, { "id": "442219", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "Closing since FR passed as well.", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2018-10-02T17:54:34.000+0000", "updated": "2018-10-02T17:54:34.000+0000" } ], "maxResults": 12, "total": 12, "startAt": 0 } } }