Problem
If you execute blur and then open a window, looks like the blur never happened. If you run an example with Kitchensink, the blur will work as expected. It's like there is a race condition between the execution of the blur in the textfield and the open of the window, where the window opening will take precedence.
Actual Results
The textfield never gets the blur command, when followed by a window opening.
Expected results
The textfield should blur, then the window should open.
Test case
1. Copy this code to an app.js:
// 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 : 'Win 1',
backgroundColor : '#fff'
});
var productTF1 = Ti.UI.createTextField({
borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
top : 100,
width : 250,
height : 40,
hintText : "Add Product..."
});
productTF1.addEventListener("focus", function() {
Ti.API.info("focus");
productTF1.blur();
var win2 = Titanium.UI.createWindow({
title : 'Win 2',
backgroundColor : '#fff'
});
var close_bttn = Titanium.UI.createButton({
title : "Close",
top : 10
});
close_bttn.addEventListener('click', function() {
productTF1.blur();
win2.close();
});
win2.add(close_bttn);
var data = [];
var tableView = Ti.UI.createTableView({
data : data,
top : 100
});
win2.add(tableView);
tab1.open(win2);
});
win1.add(productTF1);
var tab1 = Titanium.UI.createTab({
icon : 'KS_nav_views.png',
title : 'Tab 1',
window : win1
});
tabGroup.addTab(tab1);
// open tab group
tabGroup.open();
2. Now run the code with 2.1.3.GA on iOS 4.x.
3. If you click on the textfield, the window will open. Close the window, the textfield shouldn't be focused.
Extra info.
This is a regression. This used to work just fine with TiSDK 2.1.3.v20120915120319, now with 2.1.3.GA is broken.
Note backport request to 2_1_X branch.
Wait, what? They're trying to blur in the midle of a focus event? Why even have the text field in the first place? How is this even a valid use case?
Hello, I'm talking with the customer, so I can provide a workaround onto this. BEst, Mauro
I wonder if this is related to the issue I'm having: TC-1362
Not related to TC-1362. This is a race condition issue.
There is a behavior difference in the platform. The developer should never have to call blur when opening a new window. Test Case below. 1. Set inTab to true and notice that returning to previous window brings up the keyboards 2. Set inTab to false and notice that the keyboard remains hidden.
Pull pending https://github.com/appcelerator/titanium_mobile/pull/3285
3_0_X backport https://github.com/appcelerator/titanium_mobile/pull/3292 2_1_X backport https://github.com/appcelerator/titanium_mobile/pull/3293
Tested with 2.1.4.v20121030173408 on iPhone 4s 6.0