Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15926] iOS: Removing a TextField without blur results in layout issue

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionCannot Reproduce
Resolution Date2017-07-10T21:35:59.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterMartin Guillon
AssigneeEric Merriman
Created2012-12-26T09:48:38.000+0000
Updated2017-07-10T21:36:03.000+0000

Description

*Steps to reproduce* 1. TextField in a ScrollView (same with TableView) 2. Focus the TextField 3. Remove the ScrollView without sending blur to the TextField 4. Add the ScrollView again 5. Observe layout bug *Test case*
var win = Titanium.UI.createWindow();
win.backgroundColor = '#ccc';

var view4 = Ti.UI.createView({
	top : 1,
	left : 5,
	right : 5,
	height : 200,
	backgroundColor : 'black',
	layout : 'vertical'
})

var scrollView = Titanium.UI.createScrollView({
	top : 0,
	height : 50,
	layout : 'vertical'
});

var button1 = Titanium.UI.createButton({
	top : 5,
	width : 130,
	height : 40,
	title : 'unfocus'
});
button1.addEventListener('click', function() {
	textfield.blur();
});

var button2 = Titanium.UI.createButton({
	top : 5,
	width : 130,
	height : 40,
	title : 'show/hide'
});
button2.addEventListener('click', onClick);

var view = Ti.UI.createView({
	backgroundColor : 'blue',
	top : 5,
	height : 30,
	bottom : 5,
	layout : 'horizontal',
	horizontalWrap : 'false',
	width : Ti.UI.FILL
})
view.add(Ti.UI.createLabel({
	left : 0,
	width : 130
}))

var textfield = Ti.UI.createTextField({
	left : 5,
	right : 5,
	height : 35,
	value : "test",
	backgroundColor : 'red',
	width : Ti.UI.FILL
})
view.add(textfield)
scrollView.add(view);

view4.add(scrollView);
view4.add(button1);
view4.add(button2);

var button = Titanium.UI.createButton({
	title : 'show/hide',
	height : 40,
	width : 200,
	bottom : 10
});
win.add(button);

var added = false;

function onClick() {
	if (added) {
		win.remove(view4);
	} else {
		win.add(view4);
		textfield.focus();
	}
	added = !added;
}

button.addEventListener('click', onClick);
win.open();

Comments

  1. Davide Cassenti 2013-01-28

    Hello, What are the steps to reproduce? I tried with the sample code, but I can't see anything weird. What should I see?
  2. Martin Guillon 2013-01-31

    @Davide: just 1 open 2 click show/hide at the bottom 3 without doing unfocus click show/hide in the "dialog view. 4 click show/hide at the bottom => the textfield is out of place. Do the same thing by adding 3.a unfocus, and it will behave correctly I just did it in the ios simulator 6.0 with sdk 3.0.0.GA
  3. Lee Morris 2017-07-10

    I am unable to reproduce this issue with the following environment; iPhone 6 (10.0) Studio 4.9.0.201705302345 Ti SDK 6.1.1 GA Appc NPM 4.2.9 Appc CLI 6.2.2 Ti CLI 5.0.14 Alloy 1.9.11 Xcode 8.2 (8C38) Node v4.8.2 Java 1.8.0_131

JSON Source