[TIMOB-11664] Android: TabGroup: Tabgroup focus event fired twice on application launch and one of those with source as undefined
| GitHub Issue | n/a | 
|---|---|
| Type | Bug | 
| Priority | High | 
| Status | Closed | 
| Resolution | Fixed | 
| Resolution Date | 2012-11-13T02:55:08.000+0000 | 
| Affected Version/s | Release 3.0.0 | 
| Fix Version/s | Release 3.0.0, Release 3.1.0, 2012 Sprint 23 API, 2012 Sprint 23 | 
| Components | Android | 
| Labels | 3.0.0beta2, api, module_tabgroup, qe-and100112, qe-testadded, regression | 
| Reporter | Satyam Sekhri | 
| Assignee | Ping Wang | 
| Created | 2012-11-05T11:51:03.000+0000 | 
| Updated | 2012-12-04T18:06:07.000+0000 | 
Description
	Tabgroup focus event fired twice on launch of application with tabgroup.
This is a regression and does not happen on 2.1.3 and 2.1.4
Steps to Reproduce:
1. Create an application with code below
2. Launch the application and check console
Actual Result:
The tabgroup focus event is fired twice and one of those have source undefined. Following are the console logs:
I/TiAPI(8612):  -------------> win1 focus event fired! - win 1
I/TiAPI(8612):  -------------> tab1 focus event fired! - Tab 1
I/TiAPI(8612):  -------------> tabGroup focus event fired! - Tab 1
I/TiAPI(8612):  -------------> tabGroup focus event fired! - undefined
Expected Result:
The tabgroup focus event should be fired only once
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();
focus event is propagating when it shouldn't.
PR: https://github.com/appcelerator/titanium_mobile/pull/3402
For FR, please run the above test case for 'android:targetSdkVersion="8"' and 'android:targetSdkVersion="14"' to make sure it works fine for both old-style tabgroup and action bar style tabgroup.
3_0_X PR: https://github.com/appcelerator/titanium_mobile/pull/3418
Closing as fixed. Tested on: Titanium Studio, build: 3.0.0.201211301903 Titanium SDK, builds: 3.0.0.v20121130200208; 3.1.0.v20121203181001 Devices: Samsung Galaxy S III (4.0.4)