Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4976] iOS: unexpected behavior from expanding textArea

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-03-06T13:01:18.000+0000
Affected Version/sRelease 1.8.0
Fix Version/sSprint 2012-05, Release 2.0.0
ComponentsiOS
Labelsmodule_textarea, qe-testadded
ReporterJon Alter
AssigneeVishal Duggal
Created2011-08-10T09:27:53.000+0000
Updated2012-03-14T14:12:06.000+0000

Description

Getting unexpected behavior from a textArea. The purpose of this sample is to create an expandable text area. When you add 3 lines of text, tap on the window blur to the textArea, tap on the textArea to refocus, the text in the textArea will scroll up. Step 1: run the code below Step 2: enter 3 lines of text into the textArea Step 3: tap the window or press return to blur the textArea Step 4: tap on the textArea to focus on the textArea Step 5: notice the contents of the textArea will scroll up
var textHeight;

if (Ti.Platform.osname == 'iphone')
	textHeight = 24;
else if (Ti.Platform.osname == 'android')
	textHeight = 34;

var l1 = Titanium.UI.createLabel({
    height:'auto',
	width:182,
    font:{fontSize:12,fontFamily:'ARIAL', fontWeight:'solid'},
	color:'#000',
	textAlign:'left',
	borderWidth:0,
	top:20,
	borderWidth:2,
	borderColor:'#bbb',
	borderRadius:10	
});
	
var tf = Titanium.UI.createTextArea({
    height:textHeight,
	width:200,
    font:{fontSize:12,fontFamily:'ARIAL', fontWeight:'solid'},
    color:'#000',
    textAlign:'left',
	color:'#777',
	paddingLeft:0,
	borderWidth:0,
	borderStyle:Titanium.UI.INPUT_BORDERSTYLE_NONE,
	top: 60,
	borderWidth:2,
	borderColor:'#bbb',
	borderRadius:10
});

tf.scrollable = false;

var last_height = tf.height;

tf.addEventListener('change',function(e)
{
	l1.text = tf.value;

	setTimeout ( function () 
	{

		if (e.value == "")
			tf.height = textHeight;
		else
			tf.height= (l1.height>textHeight) ? l1.height + 8 : textHeight;
			
		if (last_height != tf.height)
			onHeightChange();

		last_height = tf.height;
		
	}	,50);
	
});

function onHeightChange (){
	Ti.API.info("add custom draw code")
}

var win1 = Titanium.UI.createWindow({backgroundColor:'white'});
win1.add(l1);
win1.add(tf);
win1.addEventListener('click', function(e){
	tf.blur();
});
win1.open();

Associated Helpdesk Ticket

http://appc.me/c/RUT-47599-528

Comments

  1. Vishal Duggal 2012-03-05

    Pull pending #1559
  2. Wilson Luu 2012-03-14

    Closing bug. Verified fix on: SDK build: 2.0.0.v20120314090311 Titanium Studio, build: 2.0.0.201203132050 xcode: 4.2 Device: iphone 4s (5.0.1)

JSON Source