Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11903] Android: TextField in a TableViewRow loses focus mysteriously and can't be focused with .focus()

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionWon't Fix
Resolution Date2012-12-06T20:28:39.000+0000
Affected Version/sn/a
Fix Version/s2012 Sprint 25, 2012 Sprint 25 API
ComponentsAndroid
Labelsandroid, defect, focus, titanbeta, triage
ReporterShawn Lipscomb
AssigneeDaniel Sefton
Created2012-11-28T23:10:24.000+0000
Updated2013-03-27T22:28:42.000+0000

Description

Problem

TextField (on a TableViewRow) loses focus mysteriously after being focused with a click. The keyboard pops up correctly, but then focus is removed from the TextField (blur does fire), even though the keyboard remains. Typing on the keyboard does not affect the TextField. A second click of the TextField focuses it and the keyboard works. Also, the same TextField can't be focused with .focus()...the call to .focus() is simply ignored.

Testcase

{panel:title=app.js}
var win1 = Ti.UI.createWindow({  
    backgroundColor:'black'
});

win1.addEventListener('open',MainWinLoad);
  function MainWinLoad()
  {
  Ti.API.info('--> trying to focus the text field');
    TheTextField.focus();
  }

var TheListBox=Ti.UI.createTableView({width:'auto'});
var BIRow=Ti.UI.createTableViewRow({color:'white',
                                    title:'No background image',
                                    height:120});
var TheTextField=Ti.UI.createTextField({keyboardType:Ti.UI.KEYBOARD_DEFAULT,
                                          returnKeyType:Ti.UI.RETURNKEY_DEFAULT,
                                          autocorrect:false,
                                          width:100,
                                          top:55,
                                          left:2
                                         });
BIRow.add(TheTextField);

TheListBox.appendRow(BIRow);

win1.open();
win1.add(TheListBox);
{panel}

Comments

  1. Natalie Huynh 2012-11-29

    Tested this back to 2.1.2.GA and still see the same behavior on Samsung SIII 4.0.4
  2. Vishal Duggal 2012-12-06

    The textfield does not focus because the underlying native view is not realized when the open event is fired. Due to limitations of the underlying OS we do not support placing textfield/textareas inside tableview rows. See the discussion in the linked tickets TIMOB-8332 and TIMOB-8869 Marking the ticket as wont fix.

JSON Source