Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6873] Android: Inconsistent Focus and Blur events with Textfield in TableViewRow

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-02-14T23:29:04.000+0000
Affected Version/sRelease 1.7.5, Release 1.8.0.1, Release 2.0.0
Fix Version/sSprint 2012-03, Release 2.0.0, Release 1.8.2
ComponentsAndroid
Labelsmodule_textfield, parity, qe-testadded
ReporterEduardo Gomez
AssigneeAllen Yeung
Created2011-12-27T08:27:04.000+0000
Updated2013-11-07T05:32:37.000+0000

Description

Issue

Focus and Blur Events are getting triggered slightly different as they are on iPhone Platform. They are getting triggered for each and every digit/character entered by the user even if he/she is entering the data in the same Text Field.

Tested on

iOS Simulator / iPhone 3Gs iOS 5 Android HVGA Emulator / LG Ally v2.2.1

Expected behavior

While entering to a Text Field Focus got fired once While selecting another TextField, Blur - Focus got fired (in that order, once).

Unexpected behavior

While entering to a Text Field Focus got fired twice, and every time a digit is entered While selecting another TextField, Blur - Focus got fired TWICE, and every time digits are entered.

Steps to reproduce

1) Select a TextField 2) Select any other TextFields in order to trigger Blur and Focus events respectively 3) Notice the difference between each platform

Repro sequence

This sample uses an "alert box" to reproduce the issue.
var win = Ti.UI.createWindow({
	softInputMode : (Titanium.UI.Android) ? Ti.UI.Android.SOFT_INPUT_ADJUST_PAN : '',
	windowSoftInputMode : (Titanium.UI.Android) ? Ti.UI.Android.SOFT_INPUT_ADJUST_PAN : ''
});

var tf1 = null;

function addRow() {
	var row = Ti.UI.createTableViewRow({
		height : 80,
		//touchEnabled:false
	});
	
	tf1 = Titanium.UI.createTextField({
		color : '#336699',
		width : 250,
		height : 80,
		focusable : true,
		returnKeyType : Titanium.UI.RETURNKEY_DONE,
		//autocapitalization : Titanium.UI.TEXT_AUTOCAPITALIZATION_WORDS,
		autocorrect : false,
		suppressReturn : true,

	});
	
	tf1.addEventListener('focus', function() {
		Ti.API.info('Focus fired');
		alert('Focus fired');
	});

	tf1.addEventListener('blur', function() {
		Ti.API.info('blur fired');
		alert('Blur fired');
	});
	
	row.add(tf1);
	//row.selectionStyle = Ti.UI.iPhone.TableViewCellSelectionStyle.NONE;
	//row.className = 'control';
	return row;
}

// create table view data object
var data = [];

for(var x = 0; x < 10; x++) {
	data[x] = addRow();
}

var tableView = Ti.UI.createTableView({
	data : data,
	//style : Titanium.UI.iPhone.TableViewStyle.GROUPED
});

win.add(tableView);

win.open();

Customer's remarks

{noformat} For every character hit on keypad the 'focus' and 'blur' are firing. Anyways you can fire an event or something like that to that that these events are firing for each key hit on keypad. In our app I was firing an event to update another view on the same window and was not showing any alert but its behaving the same way. {noformat}

Comments

  1. Nikolai Derzhak 2012-02-06

    This issue latest notification was not sent due to JIRA mail setting. Fixed now. Please check the issue for latests changes.
  2. Eric Merriman 2012-02-13

    Verified fixed with SDK 1.9.0.v20120212011634 Droid 3 (2.3.4) and Nexus S (2.2.2) as well as emulator with both Rhino and V8 runtimes.
  3. Shameer Jan 2013-11-07

    Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/4863

JSON Source