GitHub Issue | n/a |
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-06-18T12:54:41.000+0000 |
Affected Version/s | Release 2.0.0, Release 2.1.0, Release 2.0.1 |
Fix Version/s | Release 2.1.0, Sprint 2012-12 API |
Components | Android |
Labels | api, module_window, qe-testadded, regression |
Reporter | Davide Cassenti |
Assignee | Hieu Pham |
Created | 2012-05-18T07:56:57.000+0000 |
Updated | 2013-12-10T06:19:54.000+0000 |
Problem
A call to a window's close() method is ignored when it is executed from that window's "open" event handler.
Works in SDK 1.8.2
Broken in SDK 2.0.2.GA
Expected behavior
The window should open for a moment, fully display, and then close.
Actual behavior
The window opens, shows, and stays there, as if no close() were called.
app.js:
var win1 = Ti.UI.createWindow({
backgroundColor:'#fff',
exitOnClose:true,
navBarHidden:false
});
var label1 = Ti.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:Ti.UI.SIZE,
top:100
});
win1.add(label1);
var btn1 = Ti.UI.createButton({
title:'Open 2nd window',
width:Ti.UI.SIZE,
left:10,
top:175
});
function DoBtn1Click()
{
var win2=Ti.UI.createWindow({
url:'win2.js',
layout:'vertical',
exitOnClose:false,
navBarHidden:false
});
win2.open();
}
btn1.addEventListener('click',DoBtn1Click);
win1.add(btn1);
win1.open();
win2.js:
var win2=Ti.UI.currentWindow;
Ti.API.info('setting open event handler');
win2.addEventListener('open',Win2Load);
function Win2Load()
{
Ti.API.info('open event handler executing');
win2.close();
Ti.API.info('open event handler done');
}
var label2 = Ti.UI.createLabel({
color:'red',
text:'I am Window 2.\nIf you can read this, then the close() failed.',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:Ti.UI.SIZE,
top:100
});
win2.add(label2);
Ti.API.info('end of js code');
Additional notes
By replacing:
win2.close();
with this:
setTimeout(function() {
win2.close();
}, 500);
The window closes correctly also in 2.0.2.GA
Another test case:
1. Click on button. You should see another window opens for a split second then closes.
Closing issue Tested with Ti Studio build 2.1.0.201206172244 Ti Mobile SDK2.1.0.v20120618134156 hash r00905cd0 OSX Lion 10.7.3 Nexus S OS 4.0.4 The expected behavior is shown
Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/4967