Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10548] Android:Tableview:Soft keyboard launch revokes focus from rows (containing textfield)

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2013-06-14T18:50:24.000+0000
Affected Version/sRelease 2.1.2, Release 3.1.0
Fix Version/s2013 Sprint 12 API
ComponentsAndroid
Labelsapi, qe-and082012
ReporterShyam Bhadauria
AssigneePing Wang
Created2012-08-22T05:08:38.000+0000
Updated2017-03-29T22:39:14.000+0000

Description

This is not a regression. It occurs as far as 2.0.1. However it works fine with 1.8.2. The app contains tableview. Its data has tableviewrow which contains textfield in it. So when this textfield is focused to bring up the softkeyboard, the focus is lost from the textfield with soft keyboard remaining visible on the screen.User has to click once more to bring the focus on textfield and to do entry into it. Steps to reproduce: 1) Use the code below and run the app
var win = Ti.UI.createWindow({
	fullscreen : false ,
	backgroundColor : 'white'
});
		
		var tableView = Ti.UI.createTableView({
		    top : '0dp',
		    bottom : '0dp',
		    left : '0dp',
		    right : '0dp'
		});
		 
		var numRows = 15;
		var rows = [];
	
		for (var i = 0; i < numRows; i++){
		    var tableViewRow = Ti.UI.createTableViewRow({
		        height : 'auto'
		    });
		     
		    var textField = Ti.UI.createTextField({
		        top:'0dp',
		        left : '5dp',
		        right : '5dp',
		        borderColor : '#CCCCCC',
		        borderStyle : Ti.UI.INPUT_BORDERSTYLE_BEZEL
		    });
		     
		    tableViewRow.add(textField);
		    rows.push(tableViewRow);
		}
		tableView.data = rows;
		win.add(tableView);
		win.open();
2. Click any textfield to bring up the soft keyboard Expected result: 2. After step 2, the soft keyboard should pop up on the screen and textfield should remain focused for writing into it. Actual result: 2. After step 2, the soft keyboard is displayed on screen but focus on textfield is lost

Comments

  1. jithinpv 2013-02-26

    The problem is still existing in version 3.0.2 and 3.1.0. Other observations: In the first click ,the soft keyboard appears and disappears in a moment, but in the future clicks the soft keyboard won't disappear. In the first click the text field losses its focus, but in the second click it will gain focus. Also there is another issue that ,we will able to input only one character when the text field get focused. After entering a character the focus will be lost. So we have to tap again to get the focus.
  2. Davide Cassenti 2013-06-14

    This sample code reproduces the issue as well:
       var win = Ti.UI.createWindow({
       	backgroundColor: "black"
       });
       var tbl = Ti.UI.createTableView();
       
       var row = Ti.UI.createTableViewRow();
       
       var txt = Ti.UI.createTextField({
       	width: "100dp"
       });
       row.add(txt);
       
       tbl.setData([row]);
       
       win.add(tbl);
       win.open();
       
  3. Ping Wang 2013-06-14

    This is not a Titanium bug. It's the Android native behavior. When the textfield is clicked, it gains the focus so the softkeyboard shows and the table view needs to re-layout. After re-layout, everything is re-drawn and the textfield loses the focus. Similar discussion is [here](http://stackoverflow.com/questions/5615436/when-the-soft-keyboard-appears-it-makes-my-edittext-field-lose-focus). If we want to edit the textfield in the tableview, we need to set "windowSoftInputMode: Ti.UI.Android.SOFT_INPUT_ADJUST_PAN" when creating the window. An example is attached at the end. Resolve the ticket as Invalid.
       var win = Ti.UI.createWindow({
           backgroundColor: "black",
           windowSoftInputMode : Ti.UI.Android.SOFT_INPUT_ADJUST_PAN
       });
       var tbl = Ti.UI.createTableView();
        
       var row = Ti.UI.createTableViewRow();
        
       var txt = Ti.UI.createTextField({
           width: "100dp"
       });
       row.add(txt);
        
       tbl.setData([row]);
        
       win.add(tbl);
       win.open();
       
  4. Lee Morris 2017-03-29

    Closing ticket as invalid.

JSON Source