{ "id": "110658", "key": "TIMOB-12981", "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": null, "resolutiondate": null, "created": "2013-03-05T23:09:25.000+0000", "priority": null, "labels": [], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:03:47.000+0000", "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" } }, "components": [], "description": "*Problem*\r\nI've created a sample app with a tabgroup and a number of subwindows in each tab. I want the user to start at the root window of each tab when switching between those tabs. So, the window stack in each tab should not be maintained as is the default. I registered an event listener on each subwindow which closes this window on blur of the (previous) tab. This works, except that the last window (the one on top of the stack) is not closed at that time, but only after the user returns to this same tab again.\r\n\r\nI've added an example app which demonstrates the problem.\r\n\r\n*Actual Result*\r\nBelow is the output with comments added\r\n\r\nOpen app, open tab 1, click button to open subwindow 1/2, click button to open subwindow 1/3:\r\n\r\n[INFO] : \b\b \b Focused tabgroup Tab 1\r\n[INFO] : \b\b \b Opened window Window 1/1\r\n[INFO] : \b\b \b Focused window Window 1/1\r\n[INFO] : \b\b \b Blurred window Window 1/1\r\n[INFO] : \b\b \b Opened window Window 1/2\r\n[INFO] : \b\b \b Focused window Window 1/2\r\n[INFO] : \b\b \b Blurred window Window 1/2\r\n[INFO] : \b\b \b Opened window Window 1/3\r\n[INFO] : \b\b \b Focused window Window 1/3\r\n\r\nSubwindow 1/3 is now on the top of the stack.\r\nClick on tab 2:\r\n\r\n[INFO] : \b\b \b Blurred window Window 1/3\r\n[DEBUG] : \b\b \bFiring app event: app:reset\r\n[INFO] : \b\b \b Blurred tabgroup Tab 1\r\n[INFO] : \b\b \b Focused tabgroup Tab 2\r\n\r\nMy event listener fires on the two subwindows in tab 1:\r\n\r\n[INFO] : \b\b \b Closing window Window 1/2 on app:reset\r\n[INFO] : \b\b \b Closing window Window 1/3 on app:reset\r\n\r\nThe close event arrives at Window 1/2, but not at Window 1/3\r\n\r\n[INFO] : \b\b \b Closed window Window 1/2\r\n\r\nTab 2 / window 2/1 opens\r\n\r\n[INFO] : \b\b \b Opened window Window 2/1\r\n[INFO] : \b\b \b Focused window Window 2/1\r\n\r\nClick again on tab 1, tab 2 blurs\r\n\r\n[INFO] : \b\b \b Blurred window Window 2/1\r\n[DEBUG] : \b\b \bFiring app event: app:reset\r\n[INFO] : \b\b \b Blurred tabgroup Tab 2\r\n[INFO] : \b\b \b Focused tabgroup Tab 1\r\n\r\nHey, why does my last subwindow in tab1 get focus, blur and close now?\r\n\r\n[INFO] : \b\b \b Focused window Window 1/3\r\n[INFO] : \b\b \b Blurred window Window 1/3\r\n[INFO] : \b\b \b Focused window Window 1/1\r\n[INFO] : \b\b \b Closed window Window 1/3\r\n\r\nOf course, from a user / UI / animation perspective the right things happen, but from a view hierarchy standpoint this is pretty undesirable.\r\n\r\n*Expected Behavior* would be (AFAICT):\r\n\r\n[INFO] : \b\b \b Focused tabgroup Tab 1\r\n[INFO] : \b\b \b Opened window Window 1/1\r\n[INFO] : \b\b \b Focused window Window 1/1\r\n[INFO] : \b\b \b Blurred window Window 1/1\r\n[INFO] : \b\b \b Opened window Window 1/2\r\n[INFO] : \b\b \b Focused window Window 1/2\r\n[INFO] : \b\b \b Blurred window Window 1/2\r\n[INFO] : \b\b \b Opened window Window 1/3\r\n[INFO] : \b\b \b Focused window Window 1/3\r\n[INFO] : \b\b \b Blurred window Window 1/3\r\n[DEBUG] : \b\b \bFiring app event: app:reset\r\n[INFO] : \b\b \b Blurred tabgroup Tab 1\r\n[INFO] : \b\b \b Focused tabgroup Tab 2\r\n[INFO] : \b\b \b Closing window Window 1/2 on app:reset\r\n[INFO] : \b\b \b Closing window Window 1/3 on app:reset\r\n[INFO] : \b\b \b Closed window Window 1/2\r\n[INFO] : \b\b \b Closed window Window 1/3 <--- Close this window now\r\n[INFO] : \b\b \b Opened window Window 2/1\r\n[INFO] : \b\b \b Focused window Window 2/1\r\n[INFO] : \b\b \b Blurred window Window 2/1\r\n[DEBUG] : \b\b \bFiring app event: app:reset\r\n[INFO] : \b\b \b Blurred tabgroup Tab 2\r\n[INFO] : \b\b \b Focused tabgroup Tab 1\r\n[INFO] : \b\b \b Focused window Window 1/1\r\n\r\n*Test Case*\r\n\r\n{code}\r\nvar tabGroup = Ti.UI.createTabGroup();\r\n\r\ntabGroup.addEventListener(\"focus\", function(event) {\r\n\tTi.API.info(\"Focused tabgroup \" + event.tab.title);\r\n});\r\n\r\ntabGroup.addEventListener(\"blur\", function(event) {\r\n\t/* When blurring the tab, close all open (sub)windows */\r\n\tTi.App.fireEvent(\"app:reset\");\r\n\tTi.API.info(\"Blurred tabgroup \" + event.previousTab.title);\r\n});\r\n\r\nfunction createWindow(title, count, closeOnReset) {\r\n\tvar win = Ti.UI.createWindow({\r\n\t\ttitle: title + \"/\" + count,\r\n\t\tbackgroundColor: '#ffffff',\r\n\t\tbackButtonTitle: 'Back',\r\n\t});\r\n\t\r\n\twin.addEventListener(\"open\", function(event) {\r\n\t\tTi.API.info(\"Opened window \" + event.source.title);\r\n\t});\r\n\t\r\n\twin.addEventListener(\"focus\", function(event) {\r\n\t\tTi.API.info(\"Focused window \" + event.source.title);\r\n\t});\r\n\t\r\n\twin.addEventListener(\"blur\", function(event) {\r\n\t\tTi.API.info(\"Blurred window \" + event.source.title);\r\n\t});\r\n\t\r\n\twin.addEventListener(\"close\", function(event) {\r\n\t\tTi.API.info(\"Closed window \" + event.source.title);\r\n\t});\r\n\t\r\n\tif (closeOnReset) {\r\n\t\tvar reset = function (event) {\r\n\t\t\tTi.API.info(\"Closing window \" + win.title + \" on app:reset\");\r\n\t\t\twin.close({ animated: false });\r\n\t\t\tTi.App.removeEventListener(\"app:reset\", reset);\r\n\t\t}\r\n\t\t\t\t\r\n\t\tTi.App.addEventListener(\"app:reset\", reset);\r\n\t}\r\n\t\r\n\tvar button = Ti.UI.createButton({\r\n\t\ttitle: 'Open ' + title + \"/\" + (count+1)\r\n\t});\r\n\tbutton.addEventListener(\"click\", function (event) {\r\n\t\ttabGroup.activeTab.open(createWindow(title, count+1, true));\r\n\t});\r\n\twin.add(button);\t\r\n\t\r\n\treturn win;\r\n};\r\n\r\n\r\n/* Create three tabs and three root windows */\r\nfor (var i = 1; i <= 3; i++) {\r\n\ttabGroup.addTab(Ti.UI.createTab({\r\n\t\ttitle: 'Tab ' + i,\r\n\t\t/* Do not send app:reset on close of root window */\r\n\t\twindow: createWindow('Window ' + i, 1, false) \r\n\t}));\r\n}\r\n\r\ntabGroup.setActiveTab(0);\r\ntabGroup.open();\r\n{code}\r\n", "attachment": [ { "id": "35931", "filename": "app.js", "author": { "name": "morinel", "key": "morinel", "displayName": "Jeroen van Vianen", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-03-05T23:09:25.000+0000", "size": 1775, "mimeType": "application/x-javascript" } ], "flagged": false, "summary": "iOS: Closing subwindows in tabgroup does not close final window right away when selecting other tab", "creator": { "name": "morinel", "key": "morinel", "displayName": "Jeroen van Vianen", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Ti 3.0.2, iOS 6.1 Simulator", "comment": { "comments": [], "maxResults": 0, "total": 0, "startAt": 0 } } }