Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27694] Android: Textfield.focus() method is not working in Ti SDK 8.3.0.GA

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2020-01-03T17:28:29.000+0000
Affected Version/sRelease 8.2.1, Release 8.3.0
Fix Version/sRelease 8.3.1
ComponentsAndroid
LabelsengSchedule, escalation
ReporterMotiur Rahman
AssigneeChristopher Williams
Created2019-12-20T14:24:47.000+0000
Updated2020-07-16T04:58:48.000+0000

Description

*Issue:* Textfield.focus() method is not working properly on android after updating to 8.3.0. It is getting focused but no keyboard is shown. The keyboard is only showing on the click of the TextField but if I call TextField.focus() then textfield is getting focused without a keyboard. *Steps To Reproduce:* 1. Create a classic project 2. Paste this code in app.js file 3. Run it on android device or emulator 4. Click on the "Focus Test" Button *Note: Works as expected with Ti SDK 8.2.0.GA*
var win = Ti.UI.createWindow({
	title : "Focus Test",
	backgroundColor : 'red',
	layout : "vertical"

});

// Create a TextField.
var aTextField = Ti.UI.createTextField({
	height : 40,
	top : 30,
	left : 20,
	right : 20,
	backgroundColor : "gray",
	hintText : 'This is hint text',
	softKeyboardOnFocus : Ti.UI.Android.SOFT_KEYBOARD_DEFAULT_ON_FOCUS, // Android only
	keyboardType : Ti.UI.KEYBOARD_DEFAULT,
	returnKeyType : Ti.UI.RETURNKEY_DEFAULT,
	borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED
});

// Listen for return events.
aTextField.addEventListener('return', function(e) {
	aTextField.blur();
	alert('Input was: ' + aTextField.value);
});

// Add to the parent view.
win.add(aTextField);

// Create a Button.
var test = Ti.UI.createButton({
	title : 'Focus Test',
	height : Ti.UI.SIZE,
	width : Ti.UI.SIZE,
	top : 50,

});

// Listen for click events.
test.addEventListener('click', function() {

	aTextField.focus();
	//alert('\'aButton\' was clicked!');
});

// Add to the parent view.
win.add(test);

win.open();

Comments

  1. Christopher Williams 2019-12-20

    master/9.0.0: https://github.com/appcelerator/titanium_mobile/pull/11405 8_3_X backport: https://github.com/appcelerator/titanium_mobile/pull/11406
  2. Christopher Williams 2019-12-20

    I've supplied a very small patch for master (9.0.0 target) and a backport for 8_3_X branch if we wanted to ask them to try a non-GA maintenance build as a fix (ti sdk install -b 8_3_X) if/once it gets merged and built. For now a simple workaround is to explicitly set the editable property to true on the textfield.
       // Create a TextField.
       var aTextField = Ti.UI.createTextField({
               editable: true, // this should work around the issue
       	height : 40,
       	top : 30,
       	left : 20,
       	right : 20,
       	backgroundColor : "gray",
       	hintText : 'This is hint text',
       	softKeyboardOnFocus : Ti.UI.Android.SOFT_KEYBOARD_DEFAULT_ON_FOCUS, // Android only
       	keyboardType : Ti.UI.KEYBOARD_DEFAULT,
       	returnKeyType : Ti.UI.RETURNKEY_DEFAULT,
       	borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED
       });
       
  3. Lokesh Choudhary 2020-01-03

    Verified the fix with SDK 8.3.1.v20191220101805 & 9.0.0.v20200103081513. Closing.
  4. Ewan Harris 2020-02-26

    Removing from fixVersion 9.0.0 as this shipped in 8.3.1.GA

JSON Source