Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18155] iOS: Tab doesn't fire FOCUS event when switching while TabGroup is inside a TableView

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-12-10T22:29:43.000+0000
Affected Version/sRelease 3.5.0
Fix Version/sRelease 3.5.0, Release 4.0.0
ComponentsiOS
Labelsqe-3.5.0
ReporterKajenthiran Velummaylum
AssigneeVishal Duggal
Created2014-12-09T07:44:24.000+0000
Updated2014-12-11T22:33:25.000+0000

Description

First Tab of a TabGroup is not firing *FOCUS* event when switching between tabs while the TabGroup is inside a TableView.

Steps To Reproduce

1. Create a classic app using following code
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');

var tbl_data = [
	{title:'Row 1'},
	{title:'Row 2'},
	{title:'Row 3'}
];

var table = Titanium.UI.createTableView({
	data:tbl_data
});

table.addEventListener('click', function(event) {
	
	var tabGroup = Titanium.UI.createTabGroup();

	var win1 = Titanium.UI.createWindow({  
		name:'win1',
    	title:'Tab 1',
    	backgroundColor:'#fff'
	});
	var tab1 = Titanium.UI.createTab({  
		name:'tab1',
	    icon:'KS_nav_views.png',
   		title:'Tab 1',
    	window:win1
	});

	var win2 = Titanium.UI.createWindow({  
		name:'win2',
    	title:'Tab 2',
    	backgroundColor:'#fff'
	});
	var tab2 = Titanium.UI.createTab({ 
		name:'tab2', 
    	icon:'KS_nav_ui.png',
    	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();
});


table.setData(tbl_data);
var win = Ti.UI.createWindow();
win.add(table);
win.open();
2. Run the app in iOS device 3. Switch between Tab1 and Tab2 few times

Actual Result

Tabs are *not triggered* focus event properly for every time. Following is the console log:
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> tab1 focus event fired! - tab1
[INFO] :   -------------> win1 focus event fired! - win1
[INFO] :   **************> win1 blur event fired! - win1
[INFO] :   **************> tab1 blur event fired! - tab1
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> tab2 focus event fired! - tab2
[INFO] :   -------------> win2 focus event fired! - win2
[INFO] :   **************> win2 blur event fired! - win2
[INFO] :   **************> tab2 blur event fired! - tab2
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> win1 focus event fired! - win1
[INFO] :   **************> win1 blur event fired! - win1
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> win2 focus event fired! - win2
[INFO] :   -------------> tab2 focus event fired! - tab2
[INFO] :   **************> win2 blur event fired! - win2
[INFO] :   **************> tab2 blur event fired! - tab2
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> win1 focus event fired! - win1
[INFO] :   **************> win1 blur event fired! - win1
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> win2 focus event fired! - win2
[INFO] :   **************> win2 blur event fired! - win2
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> win1 focus event fired! - win1
[INFO] :   **************> win1 blur event fired! - win1
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> win2 focus event fired! - win2
[INFO] :   **************> win2 blur event fired! - win2
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> win1 focus event fired! - win1
[INFO] :   **************> win1 blur event fired! - win1
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> win2 focus event fired! - win2
[INFO] :   **************> win2 blur event fired! - win2
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> win1 focus event fired! - win1
[INFO] :   **************> win1 blur event fired! - win1
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> win2 focus event fired! - win2

Expected Result

Tab focus event should be triggered properly every time. Following console log *should repeat* for every focus event.
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> tab1 focus event fired! - tab1
[INFO] :   -------------> win1 focus event fired! - win1
[INFO] :   **************> win1 blur event fired! - win1
[INFO] :   **************> tab1 blur event fired! - tab1
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> tab2 focus event fired! - tab2
[INFO] :   -------------> win2 focus event fired! - win2
[INFO] :   **************> win2 blur event fired! - win2
[INFO] :   **************> tab2 blur event fired! - tab2
[INFO] :   -------------> tabGroup focus event fired! - undefined
[INFO] :   -------------> tab1 focus event fired! - tab1
[INFO] :   -------------> win1 focus event fired! - win1

Comments

  1. Vishal Duggal 2014-12-10

    Pull pending master - https://github.com/appcelerator/titanium_mobile/pull/6466 3_5_X - https://github.com/appcelerator/titanium_mobile/pull/6467
  2. Wilson Luu 2014-12-11

    Closing ticket as fixed. Verified tab properly fires the focus event after switching between tabs. Tested on: Appcelerator Studio, build: 3.4.1.201410281743 SDK build: 3.5.0.v20141211124115 CLI: 3.4.1 Alloy: 1.5.1 Xcode: 6.2 beta Devices: iphone 6 plus (8.1.1)
  3. Wilson Luu 2014-12-11

    Verified fix.

JSON Source