{ "id": "140409", "key": "TIMOB-18080", "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": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2015-02-25T18:31:09.000+0000", "created": "2014-11-24T17:36:04.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "regression", "supportTeam" ], "versions": [ { "id": "15972", "description": "Release 3.4.0", "name": "Release 3.4.0", "archived": false, "released": true, "releaseDate": "2014-09-28" }, { "id": "16676", "description": "Release 3.4.1", "name": "Release 3.4.1", "archived": false, "released": true, "releaseDate": "2014-11-14" } ], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-22T23:03:36.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" }, { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h3. Issue \r\n\r\nIn SDK 3.3.0 and higher when a tableView is scroll and the remove from the window and then added again to the window the scroll position is lost and restored to the original starting position, in SDK 3.2.X when doing this the tableView keeps the original position\r\n\r\nh3. Steps to repro\r\n\r\n1. Run test code \r\n2. Scroll the table\r\n3. Click on a row\r\n4. Click on the \"Go Back\" button\r\n\r\nExpected Result:\r\nThe tableView will be displayed again with the last scroll position \r\n\r\nActual Result:\r\nThe tableView is displayed with the original scroll position (Y value:0)\r\n\r\nh3. Test Code\r\n\r\n{code}\r\nTitanium.UI.setBackgroundColor('#000'); \r\n\r\nvar win = Titanium.UI.createWindow({ \r\ntitle:'Tab 1', \r\nbackgroundColor:'#fff' \r\n}); \r\n\r\nvar mainView = Ti.UI.createView({ \r\ntop: 45 \r\n}); \r\n\r\nvar tableView = Ti.UI.createTableView(); \r\n\r\nvar rows = []; \r\nfor (var i = 0; i < 40; i++) { \r\nrows.push(Ti.UI.createTableViewRow({ \r\ntitle: 'Row ' + i \r\n})); \r\n}; \r\n\r\ntableView.setData(rows); \r\n\r\ntableView.addEventListener('click', function(e) { \r\nmainView.add(anotherView); \r\nmainView.remove(tableView); \r\n}); \r\n\r\nvar anotherView = Ti.UI.createView({ \r\nlayout: 'absolute' \r\n}); \r\n\r\nvar backButton = Ti.UI.createButton({ \r\ntitle: 'Go back' \r\n}); \r\n\r\nbackButton.addEventListener('click', function(e) { \r\nmainView.add(tableView); \r\nmainView.remove(anotherView); \r\n}); \r\n\r\nanotherView.add(backButton); \r\n\r\nmainView.add(tableView); \r\nwin.add(mainView); \r\n\r\nwin.open(); \r\n{code}\r\n\r\nh3. Workaround\r\n\r\nIn order to keep the las position its possible to use e.firstVisibleItem for android and e.contentOffset for iOS in order to keep a similar effect.\r\n\r\n{code}\r\nvar win = Titanium.UI.createWindow({ \r\ntitle:'Tab 1', \r\nbackgroundColor:'#fff' \r\n}); \r\n\r\nvar mainView = Ti.UI.createView({ \r\ntop: 45 \r\n}); \r\nvar tableView = Ti.UI.createTableView(); \r\n\r\nvar rows = []; \r\nfor (var i = 0; i < 40; i++) { \r\nrows.push(Ti.UI.createTableViewRow({ \r\ntitle: 'Row ' + i \r\n})); \r\n}; \r\n\r\ntableView.setData(rows); \r\n\r\n\r\n\r\ntableView.addEventListener('click', function(e) { \r\nmainView.remove(tableView); \r\nbackButton.visible=true; \r\n}); \r\n\r\n\r\n\r\nvar backButton = Ti.UI.createButton({ \r\ntitle: 'Go back', \r\ntop:10, \r\nvisible:false \r\n}); \r\nvar pos,scroll=false; \r\n\r\nbackButton.addEventListener('click', function(e) { \r\nif(Ti.Platform.osname == 'android'){ \r\ntableView.scrollToIndex(pos); \r\n}else{ \r\ntableView.scrollToTop(pos.y,false); \r\n} \r\nmainView.add(tableView); \r\n\r\nbackButton.visible=false; \r\n}); \r\n\r\n\r\ntableView.addEventListener('scroll',function(e){ \r\nif(Ti.Platform.osname == 'android'){ \r\npos = e.firstVisibleItem; \r\n}else{ \r\npos = e.contentOffset; \r\n} \r\nTi.API.info(e.firstVisibleItem); \r\n}); \r\n\r\nwin.add(backButton); \r\n\r\nmainView.add(tableView); \r\nwin.add(mainView); \r\n\r\nwin.open();\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "TableView: When removing the window and attaching it again scroll position is lost", "creator": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "iOS: 7/8\r\nTiSDK: 3.3.0 / 3.4.0 / 3.4.1", "closedSprints": [ { "id": 356, "state": "closed", "name": "2015 Sprint 05 SDK", "startDate": "2015-02-28T15:50:08.527Z", "endDate": "2015-03-14T00:00:00.000Z", "completeDate": "2015-03-14T13:54:50.695Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "344335", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "contentOffset and firstVisible item are not supported properties of the TableView on the Titanium platform. When a window is closed or the view is removed from the parent, the view is destroyed and recreated when the window is opened again or the view is reattached to the parent. When it is recreated only properties that are supported by the proxy are applied to the view. Hence the scroll position is lost. \r\n\r\n", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-02-25T18:31:09.000+0000", "updated": "2015-02-25T18:31:09.000+0000" }, { "id": "415204", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as \"Won't Fix\".", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-22T23:03:36.000+0000", "updated": "2017-03-22T23:03:36.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }