Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13721] Android: TextField fires change event on first initialization (SDK 3.2)

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-07-23T21:25:20.000+0000
Affected Version/sRelease 3.2.0
Fix Version/s2013 Sprint 15 API, 2013 Sprint 15, Release 3.1.2, Release 3.2.0
ComponentsAndroid
Labelsmodule_textfield, qe-closed-3.1.2, qe-testadded, regression
ReporterTommy Leung
AssigneeSunila
Created2013-04-27T00:36:08.000+0000
Updated2014-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();
*Note* This works correctly in 3.1.0.GA but seems to be broken in CI builds. It doesn't seem to make much sense since nothing changed yet, this is the starting value.

Comments

  1. Daniel Sefton 2013-04-29

    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.
  2. Biju pm 2013-05-16

    https://github.com/appcelerator/titanium_mobile/pull/4275 Removing isTruncatingText to call shouldFireChange method while change the text
  3. Ping Wang 2013-05-16

    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.
  4. Ping Wang 2013-05-16

    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);
       
    When click the button, the change event should be fired.
  5. Ping Wang 2013-07-10

    Ran the extended test case in the comment and it failed.
  6. Sunila 2013-07-23

    New pull request submitted https://github.com/appcelerator/titanium_mobile/pull/4473 Disable firing 'change' event during processproperties
  7. Olga Romero 2013-08-15

    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
  8. Priya Agarwal 2013-08-21

    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)

JSON Source