[TIMOB-18075] iOS: Window focus event is not triggered when switch back from another tab
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-12-03T21:24:57.000+0000 |
Affected Version/s | Release 3.5.0 |
Fix Version/s | Release 3.5.0, Release 4.0.0 |
Components | iOS |
Labels | Regression, module_window, qe-3.5.0, qe-manualtest |
Reporter | Kajenthiran Velummaylum |
Assignee | Vishal Duggal |
Created | 2014-11-24T08:19:47.000+0000 |
Updated | 2014-12-09T23:40:55.000+0000 |
Description
Window *Focus* Event is not triggered when we switch between tabs in iOS device.
For Android, It works fine.
This is a *regression* since it doesn't occur in SDK 3.4.1 GA
Steps To Reproduce
1. Create a default titanium classic project 2. Insert following code in your app.js file
win1.addEventListener('focus', function(){
alert('focused!');
});
3. Run the app in iOS device
4. Switch between *tab 1* and *tab 2*
Expected Result
An alert should appear with text "focused!"Actual Result
Alert does not appear with SDK version 3.5.0Tested app.js file
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win1.add(label1);
win1.addEventListener('focus', function(){
alert('focused!');
});
//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({
title:'Tab 2',
backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 2',
window:win2
});
var label2 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 2',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win2.add(label2);
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.open();
Look for changes in Window or Tab/TabGroup.
This is due to the refactor of alert dialogs and option dialogs for iOS8. Since they are now UIAlertControllers presented modally, the top most window proxy resigns focus when they are presented. We need to ensure that the top most window proxy regains focus on dismissal of Alerts/OptionDialogs
The test case above will not work. It will essentially result in an infinite loop on iOS8 since presenting alerts now blurs the window and dismissing it will refocus the window causing the focus event to fire again. Updated test case below
Pull pending master - https://github.com/appcelerator/titanium_mobile/pull/6417 3_5_X - https://github.com/appcelerator/titanium_mobile/pull/6418
Closing ticket as fixed. Verified (using Vishal's test code) focus event is triggered when switching between tabs. Appcelerator Studio, build: 3.4.1.201410281743 SDK build: 3.5.0.v20141208122514 CLI: 3.4.1 Alloy: 1.5.1 Xcode: 6.1.1 GM Devices: iphone 6 plus (8.1.1), ipad air (8.2 beta)