[TIMOB-13721] Android: TextField fires change event on first initialization (SDK 3.2)
| GitHub Issue | n/a | 
|---|---|
| Type | Bug | 
| Priority | High | 
| Status | Closed | 
| Resolution | Fixed | 
| Resolution Date | 2013-07-23T21:25:20.000+0000 | 
| Affected Version/s | Release 3.2.0 | 
| Fix Version/s | 2013 Sprint 15 API, 2013 Sprint 15, Release 3.1.2, Release 3.2.0 | 
| Components | Android | 
| Labels | module_textfield, qe-closed-3.1.2, qe-testadded, regression | 
| Reporter | Tommy Leung | 
| Assignee | Sunila | 
| Created | 2013-04-27T00:36:08.000+0000 | 
| Updated | 2014-01-27T18:50:02.000+0000 | 
Description
	*Problem description*
When a label is initialized, it fires of a change event even though nothing has changed yet
*Steps to reproduce*
1. Deploy the test case to device.
2. Check the logcat output.
3. The change event is printed.
*Test case*
var win = Ti.UI.createWindow({
	backgroundColor : "#FFF"
});
var textField = Ti.UI.createTextField({
	value : 'test123'
});
textField.addEventListener('change', function(e) {
	Ti.API.info("Change Event Fired: " + e.value);
});
win.add(textField);
win.open();
Confirmed regression on Samsung Galaxy S2 Android 2.3.6 between 3.1 GA and 3.2.0.v20130426092515. The event is fired on initialization only with 3.2.
https://github.com/appcelerator/titanium_mobile/pull/4275 Removing isTruncatingText to call shouldFireChange method while change the text
The change event is fired on first initialization in 2.1.4. There is a regression bug TIMOB-12139 in 3.0.0 and 3.1.0 and we fixed that in 3.1.1 [PR#4193](https://github.com/appcelerator/titanium_mobile/pull/4193). So the current behavior is actually the same as 2.1.4.
An extended test case:
var win = Ti.UI.createWindow({ backgroundColor : "#FFF" }); var textField = Ti.UI.createTextField({ top: 10, value : 'test123' }); textField.addEventListener('change', function(e) { Ti.API.info("Change Event Fired: " + e.value); }); win.add(textField); win.open(); var button = Ti.UI.createButton({ top: 150, title: "change textfield.value" }); button.addEventListener("click", function(){ textField.value = "changed"; }); win.add(button);Ran the extended test case in the comment and it failed.
New pull request submitted https://github.com/appcelerator/titanium_mobile/pull/4473 Disable firing 'change' event during processproperties
Tested and verified fix with: Titanium Studio, build: 3.1.2.201308091617 Titanium SDK, build: 3.1.2.v20130814124556 Alloy: 1.2.0-beta CLI: 3.1.2-alpha Device: GalaxyS4 Android version 4.2.2 Change is fired on button click
Updated label and added TestApp. Verified Environment: Studio: 3.1.3.201308201707 Sdk: 3.1.3.v20130820141614 acs:1.0.6 alloy:1.2.1-cr titanium:3.1.2 OS: OSX 10.8.4 Xcode:5 beta 5 Devices:iPhone5(v6.1.4), Android NEXUS 7(v4.3)