[TIMOB-8067] MobileWeb: Window - The focus event isn't firing each time and reports undefined for the source.name
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-04-17T22:12:04.000+0000 |
Affected Version/s | Release 2.0.0 |
Fix Version/s | Release 2.0.0, Sprint 2012-06 |
Components | MobileWeb, Windows Hybrid |
Labels | qe-mw020912, qe-port |
Reporter | Michael Pettiford |
Assignee | Bryan Hughes |
Created | 2012-03-16T15:18:43.000+0000 |
Updated | 2014-04-17T22:12:04.000+0000 |
Description
Steps to reproduce:
1. Create a default mobile web app and change the app.js code to the following:
var tabGroup = Ti.UI.createTabGroup();
var win1 = Ti.UI.createWindow({
name: "win 1"
});
var tab1 = Ti.UI.createTab({
name: "Tab 1",
title:'Tab 1',
window:win1
});
var win2 = Ti.UI.createWindow({
name: "win 2",
title:'Tab 2',
backgroundColor:'#fff'
});
var tab2 = Ti.UI.createTab({
name: "Tab 2",
title:'Tab 2',
window:win2
});
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.addEventListener('focus', function(e){
Ti.API.info('-------------> tabGroup focus event fired! - ' + e.source.name);
});
tab1.addEventListener('focus', function(e){
Ti.API.info('-------------> tab1 focus event fired! - ' + e.source.name);
});
tab2.addEventListener('focus', function(e){
Ti.API.info('-------------> tab2 focus event fired! - ' + e.source.name);
});
win1.addEventListener('focus', function(e){
Ti.API.info('-------------> win1 focus event fired! - ' + e.source.name);
});
win2.addEventListener('focus', function(e){
Ti.API.info('-------------> win2 focus event fired! - ' + e.source.name);
});
tab1.addEventListener('blur', function(e){
Ti.API.info('**************> tab1 blur event fired! - ' + e.source.name);
});
tab2.addEventListener('blur', function(e){
Ti.API.info('**************> tab2 blur event fired! - ' + e.source.name);
});
win1.addEventListener('blur', function(e){
Ti.API.info('**************> win1 blur event fired! - ' + e.source.name);
});
win2.addEventListener('blur', function(e){
Ti.API.info('**************> win2 blur event fired! - ' + e.source.name);
});
tabGroup.open();
2. Run the app
3. Tap between the two tabs
Actual result:
One focus event is fired with an undefined e.source.name
Expected result:
Focus events are fired each time a user switches between tabs
Note: the undefined e.source.name is expected. When the tabgroup fires a focus event, the source is the tabgroup, which you didn't specify a name for. I confirmed the same behavior on iOS. You can use e.tab to access the focused tab.
Pull Request: https://github.com/appcelerator/titanium_mobile/pull/1747
Verified fix on: Titanium studio : 2.1.1.201207271312 SDK version : 2.2.0.v20120814103312 Mountain lion(10.8) - chrome 21.0,safari 6,firefox 14.0.1