{ "id": "100571", "key": "TIMOB-10802", "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": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" }, { "id": "14127", "description": "Sprint 2012-19 API", "name": "Sprint 2012-19 API", "archived": true, "released": true, "releaseDate": "2012-09-24" }, { "id": "14271", "description": "2012 Sprint 19", "name": "2012 Sprint 19", "archived": true, "released": true, "releaseDate": "2012-09-24" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-09-18T18:10:58.000+0000", "created": "2012-09-06T14:27:45.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "api", "module_navgroup", "qe-testadded" ], "versions": [ { "id": "14096", "description": "Release 2.1.2", "name": "Release 2.1.2", "archived": true, "released": true, "releaseDate": "2012-08-31" } ], "issuelinks": [], "assignee": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2013-07-17T09:57:32.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": "h3. The problem:\r\n\r\nWhen closing a window programmatically in a Navigation group, only the first window in the stack (or last, depending how you look at it) fires the close event, the rest of the windows do not.\r\n\r\nh3. The steps to repro\r\n1. Run the following code in app.js\r\n2. Open a few windows with the \"open\" button\r\n3. Click on the close all button\r\n4. Look at the logs, only the last window fired the \"close\" event\r\n\r\nh3. The code:\r\n\r\n{code}\r\nfunction NavGroup() {\r\n\tvar win = Ti.UI.createWindow();\r\n\tvar nav = Ti.UI.iPhone.createNavigationGroup();\r\n\tvar allWindows = [];\r\n\twin.add(nav);\r\n\t\r\n\tfunction open(_window) {\r\n\t\tif(_window) {\r\n\t\t\tnav.open(_window);\r\n\t\t\tallWindows.push(_window);\r\n\t\t} else {\r\n\t\t\twin.open();\r\n\t\t}\r\n\t}\r\n\r\n\tfunction close(_window) {\r\n\t\tif(_window) {\r\n\t\t\tnav.close(_window);\r\n\t\t\tfor(var i = 0, len = allWindows.length; i < len; i++) {\r\n\t\t\t\tif(_window == allWindows[i]) {\r\n\t\t\t\t\tallWindows.splice(i, 1);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\twin.open();\r\n\t\t}\r\n\t}\r\n\t\r\n\tfunction setWindow(_window) {\r\n\t\tnav.window = _window;\r\n\t}\r\n\t\r\n\tfunction closeAll() {\r\n\t\tfor(var i = 0, len = allWindows.length; i < len; i++) {\r\n\t\t\tnav.close(allWindows[i]);\r\n\t\t}\r\n\t}\r\n\t\r\n\treturn {\r\n\t\topen: open,\r\n\t\tclose: close,\r\n\t\tcloseAll:closeAll,\r\n\t\tsetWindow: setWindow\r\n\t}\r\n}\r\n\r\n\r\nfunction Window(num){\r\n\tvar win = Ti.UI.createWindow({\r\n\t\tbackgroundColor: '#ccc',\r\n\t\ttitle: 'Window #'+num\r\n\t});\r\n\r\n\tvar btnOpen = Ti.UI.createButton({\r\n\t\ttitle: 'open next',\r\n\t\ttop: 10,\r\n\t\twidth: Ti.UI.SIZE,\r\n\t\theight: Ti.UI.SIZE\r\n\t});\r\n\t\r\n\tvar btnCloseAll = Ti.UI.createButton({\r\n\t\ttitle: 'close all',\r\n\t\ttop: 60,\r\n\t\twidth: Ti.UI.SIZE,\r\n\t\theight: Ti.UI.SIZE\r\n\t});\r\n\t\r\n\tvar btnCloseThis = Ti.UI.createButton({\r\n\t\ttitle: 'close this window',\r\n\t\ttop: 110,\r\n\t\twidth: Ti.UI.SIZE,\r\n\t\theight: Ti.UI.SIZE\r\n\t});\r\n\t\r\n\twin.add(btnOpen);\r\n\twin.add(btnCloseAll);\r\n\tif(num !== 1)\r\n\t\twin.add(btnCloseThis);\r\n\t\r\n\tbtnOpen.addEventListener('click', function(){\r\n\t\tnum++;\r\n\t\tNav.open(Window(num));\r\n\t});\r\n\tbtnCloseAll.addEventListener('click', function(){\r\n\t\tNav.closeAll();\r\n\t});\r\n\tbtnCloseThis.addEventListener('click', function(){\r\n\t\tNav.close(win);\r\n\t});\r\n\t\r\n\twin.addEventListener('close', function(){\r\n\t\tTi.API.info('Closing Window #' + num)\r\n\t});\r\n\t\r\n\treturn win;\r\n}\r\n\r\nvar Nav = NavGroup();\r\nNav.setWindow(Window(1));\r\nNav.open();\r\n{code}", "attachment": [], "flagged": false, "summary": "iOS: Navigation group not firing close event on windows", "creator": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "iOS\r\nTi SDK 2.1.2.GA", "comment": { "comments": [ { "id": "218456", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Expanded test case\r\n{code}\r\nfunction NavGroup() {\r\n var win = Ti.UI.createWindow();\r\n var nav = Ti.UI.iPhone.createNavigationGroup();\r\n var allWindows = [];\r\n win.add(nav);\r\n \r\n function open(_window) {\r\n if(_window) {\r\n nav.open(_window);\r\n allWindows.push(_window);\r\n } else {\r\n win.open();\r\n }\r\n }\r\n \r\n function removeWin(_window) {\r\n\t\tfor(var i = 0, len = allWindows.length; i < len; i++) {\r\n \tif(_window == allWindows[i]) {\r\n \tallWindows.splice(i, 1);\r\n break;\r\n }\r\n } \t\r\n }\r\n \r\n function close(_window,opts) {\r\n if(_window) {\r\n nav.close(_window,opts);\r\n } else {\r\n win.open();\r\n }\r\n }\r\n \r\n function setWindow(_window) {\r\n nav.window = _window;\r\n }\r\n \r\n function closeAll() {\r\n for(var i = 0, len = allWindows.length; i < len; i++) {\r\n nav.close(allWindows[i]);\r\n }\r\n }\r\n function closeAll2(opts) {\r\n for(var len = allWindows.length, i = len-1 ; i >=0 ; i--) {\r\n nav.close(allWindows[i],opts);\r\n }\r\n }\r\n return {\r\n open: open,\r\n close: close,\r\n closeAll:closeAll,\r\n closeAll2:closeAll2,\r\n setWindow: setWindow,\r\n removeWin:removeWin\r\n }\r\n}\r\n \r\n \r\nfunction Window(num){\r\n var win = Ti.UI.createWindow({\r\n backgroundColor: '#ccc',\r\n title: 'Window #'+num,\r\n number:num\r\n });\r\n \r\n var btnOpen = Ti.UI.createButton({\r\n title: 'open next',\r\n top: 10,\r\n width: Ti.UI.SIZE,\r\n height: Ti.UI.SIZE\r\n });\r\n \r\n var btnCloseThis = Ti.UI.createButton({\r\n title: 'close this (animated)',\r\n top: 60,\r\n width: Ti.UI.SIZE,\r\n height: Ti.UI.SIZE\r\n });\r\n var btnCloseThis2 = Ti.UI.createButton({\r\n title: 'close this',\r\n top: 110,\r\n width: Ti.UI.SIZE,\r\n height: Ti.UI.SIZE\r\n });\r\n\r\n var btnCloseAll = Ti.UI.createButton({\r\n title: 'close All (Back->Front)',\r\n top: 160,\r\n width: Ti.UI.SIZE,\r\n height: Ti.UI.SIZE\r\n });\r\n \r\n var btnCloseAll2 = Ti.UI.createButton({\r\n title: 'close All (Front->Back animated)',\r\n top: 210,\r\n width: Ti.UI.SIZE,\r\n height: Ti.UI.SIZE\r\n });\r\n\r\n var btnCloseAll3 = Ti.UI.createButton({\r\n title: 'close All (Front->Back)',\r\n top: 260,\r\n width: Ti.UI.SIZE,\r\n height: Ti.UI.SIZE\r\n });\r\n\r\n\r\n win.add(btnOpen);\r\n \r\n if(num !== 1)\r\n {\r\n \twin.add(btnCloseThis);\r\n \twin.add(btnCloseThis2);\r\n \twin.add(btnCloseAll);\r\n \twin.add(btnCloseAll2);\r\n \twin.add(btnCloseAll3);\r\n }\r\n \r\n \r\n btnOpen.addEventListener('click', function(){\r\n num=win.number+1;\r\n Nav.open(Window(num));\r\n });\r\n btnCloseAll.addEventListener('click', function(){\r\n Nav.closeAll();\r\n });\r\n btnCloseAll2.addEventListener('click', function(){\r\n Nav.closeAll2({animated:true});\r\n });\r\n btnCloseAll3.addEventListener('click', function(){\r\n Nav.closeAll2({animated:false});\r\n });\r\n btnCloseThis.addEventListener('click', function(){\r\n Nav.close(win,{animated:true});\r\n });\r\n btnCloseThis2.addEventListener('click', function(){\r\n Nav.close(win,{animated:false});\r\n });\r\n win.addEventListener('close', function(){\r\n \tTi.API.info('Closing Window #' + win.number)\r\n \tNav.removeWin(win);\r\n });\r\n \r\n return win;\r\n}\r\n \r\nvar Nav = NavGroup();\r\nNav.setWindow(Window(1));\r\nNav.open();\r\n{code}", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-09-11T15:20:19.000+0000", "updated": "2012-09-11T15:20:19.000+0000" }, { "id": "218463", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Pull pending https://github.com/appcelerator/titanium_mobile/pull/2909", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-09-11T15:42:54.000+0000", "updated": "2012-09-11T15:42:54.000+0000" }, { "id": "219072", "author": { "name": "dwelch", "key": "dwelch", "displayName": "David Welch", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Vishal - Please let me know when this gets put into one of the nightly releases. ", "updateAuthor": { "name": "dwelch", "key": "dwelch", "displayName": "David Welch", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-09-14T14:53:28.000+0000", "updated": "2012-09-14T14:53:28.000+0000" }, { "id": "225167", "author": { "name": "tsmolich", "key": "tsmolich", "displayName": "Tamila Smolich", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing as fixed. Tested and verified on:\r\nTitanium Studio, build: 3.0.0.201210220122\r\nTitanium SDK, build: 3.0.0.v20121025171611\r\nDevice: iPhone 5 (6.0)", "updateAuthor": { "name": "tsmolich", "key": "tsmolich", "displayName": "Tamila Smolich", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-10-26T20:47:43.000+0000", "updated": "2012-10-26T20:47:43.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }