{ "id": "147693", "key": "AC-1225", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2015-08-10T18:43:05.000+0000", "created": "2015-05-11T05:29:27.000+0000", "labels": [ "alert", "alertdialog", "event", "focus", "infinite", "ios", "issue", "listener", "times" ], "versions": [], "issuelinks": [], "assignee": { "name": "rtlechuga", "key": "rtlechuga", "displayName": "Radamantis Torres-Lechuga", "active": false, "timeZone": "Asia/Dubai" }, "updated": "2016-03-08T07:37: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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "When the alert function is called on window focus event the that alert function gets called infinite times, this is because window focus events gets on calling infinite times.\r\nAnother problem is window focus event should not call on calling alert or alertDialog.show()\r\nTest the code on iOS simulator or device to reproduce bug.\r\nBelow is the code to test the bug, window focus event should not get called infinite times when alert code is written on window focus event.\r\nCase 1:\r\nvar win1 = Titanium.UI.createWindow(\r\n{ backgroundColor : 'red', title : 'Red Window', }\r\n);\r\nvar navWin = Titanium.UI.iOS.createNavigationWindow(\r\n{ window : win1 }\r\n);\r\nwin1.addEventListener(\"focus\",function(e)\r\n{ alert(\"hello\"); Ti.API.info(\"Focus on first window\"); }\r\n);\r\nnavWin.open();\r\nCase 2:\r\nvar win1 = Titanium.UI.createWindow(\r\n{ backgroundColor : 'red', title : 'Red Window', }\r\n);\r\nvar navWin = Titanium.UI.iOS.createNavigationWindow(\r\n{ window : win1 }\r\n);\r\nvar dialog = Ti.UI.createAlertDialog(\r\n{ cancel: 1, buttonNames: ['Confirm', 'Cancel'], message: 'demo alert dialog?', title: 'Window Option' }\r\n);\r\nwin1.addEventListener(\"focus\",function(e)\r\n{ dialog.show(); Ti.API.info(\"Focus on first window\"); }\r\n);\r\nnavWin.open();\r\nYou can copy the cases in app.'s file and test the same. You can also check the debug logs which shows focus event is continuously firing.\r\nAttached are the files for both the test cases.\r\nExecute the code to find the bug.", "attachment": [ { "id": "55312", "filename": "case1.js", "author": { "name": "moizchhatriwala", "key": "moizchhatriwala", "displayName": "MoizChhatriwala", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-05-11T05:24:44.000+0000", "size": 286, "mimeType": "application/x-javascript" }, { "id": "55313", "filename": "case2.js", "author": { "name": "moizchhatriwala", "key": "moizchhatriwala", "displayName": "MoizChhatriwala", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-05-11T05:24:44.000+0000", "size": 454, "mimeType": "application/x-javascript" } ], "flagged": false, "summary": "If alert(\"hello\") or AlertDialog show function is written on window focus event then window focus event is called infinite times.", "creator": { "name": "moizchhatriwala", "key": "moizchhatriwala", "displayName": "MoizChhatriwala", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "moizchhatriwala", "key": "moizchhatriwala", "displayName": "MoizChhatriwala", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Tested in titanium SDK 3.5.1 with code written in titanium classic pattern. Same issue also exist on titanium 4.0.0 Beta 2 for iOS", "comment": { "comments": [ { "id": "359468", "author": { "name": "rtlechuga", "key": "rtlechuga", "displayName": "Radamantis Torres-Lechuga", "active": false, "timeZone": "Asia/Dubai" }, "updateAuthor": { "name": "rtlechuga", "key": "rtlechuga", "displayName": "Radamantis Torres-Lechuga", "active": false, "timeZone": "Asia/Dubai" }, "created": "2015-08-10T18:43:05.000+0000", "updated": "2015-08-10T18:43:05.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }