Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12139] Android: Textfield change event behaves differently in 2.1.4 and 3.0.0 SDK

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-04-09T22:05:02.000+0000
Affected Version/sRelease 3.0.0
Fix Version/s2013 Sprint 08 API, 2013 Sprint 08, Release 3.1.1, Release 3.2.0
ComponentsAndroid
LabelsSupportTeam, exalture, qe-testadded, regression
ReporterVarun Joshi
AssigneePing Wang
Created2012-12-20T19:48:06.000+0000
Updated2013-10-04T10:44:04.000+0000

Description

Issue

The textfield change event listener in 2.1.4 is fired differently from 3.0.0.GA SDK.

Steps to Reproduce

Run the sample below:

var win = Ti.UI.createWindow({
    backgroundColor : 'white'
});

win.open();

var view = Ti.UI.createView({
    backgroundColor : 'red',
    top : 20,
    left : 20,
    height : 400,
    width : 300,
    layout: 'vertical'
});

win.add(view);

var textfield = Ti.UI.createTextField({
    left: 20,
    right: 20,
    height: 40,
    //maxLength: 6,
    borderColor: 'black',
    borderWidth: 2,
    value: 'Hello'
});
view.add(textfield);

var countChangeEvents = 0;
textfield.addEventListener('change', function(_evt){
    countChangeEvents++;
    Ti.API.info('change event fired: ' + countChangeEvents);
    var value = _evt.source.value; 
    if (value == 'HelloA'){
        Ti.API.info('replace');
        textfield.value = value.replace('Hello', '*****');
    }
});

2. Enter the letter "A" at the end of the text in the textfield. 3. Notice the characters before A turn to "*". 4. If you look at the logs the API info statements show 2 change events fired for the above steps in 3.0.0.GA while in 2.1.4.GA, 3 events were fired. Is this an intentional behavior?

Comments

  1. Olga Romero 2013-03-13

    Tested with: Titanium Studio, build: 3.0.3.201302201202 Titanium SDK, build: 3.1.0.v20130312161655 Device: Nexus7 Android version: 4.2 Test steps: 1. Ran App and added "A" in the end of the text console output is: I/TiAPI(2913): change event fired: 1 I/TiAPI(2913): replace W/IInputConnectionWrapper(2913): endBatchEdit on inactive InputConnection 2. Each click on the keyboard's key fires event I/TiAPI(2913): change event fired: 2 I/TiAPI(2913): change event fired: 3 I/TiAPI(2913): change event fired: 4 I/TiAPI(2913): change event fired: 5 Identical result for 3.0.2.GA
  2. Ping Wang 2013-04-04

    PR: https://github.com/appcelerator/titanium_mobile/pull/4072 For FR: 1. Run the above test case. 2. Add "A" at the end of the text. Check the log, it should fire three "change" events (before the fix, it only fired one "change" event). 3. Uncomment Line 22 in the above test case {quote}maxLength: 6{quote} and then run the test case again. 4. Input more characters in the text field. It should not crash (before the fix, it crashed on 4.x devices if the total characters > 6). Check the log, the "change" event should be fired when the shown text is changed. 5. Please also follow the test instruction in TIMOB-5810.
  3. Ping Wang 2013-04-22

    3_1_X PR: https://github.com/appcelerator/titanium_mobile/pull/4193
  4. Anshu Mittal 2013-05-07

    Tested with: SDK:3.1.1.v20130503173050 Appcelerator Studio: 3.1.1.201305031846 OS: OSX 10.7.5 Device: Google nexus7(v 4.1) Logs change event successfully every time a character is added or deleted from textfield.

JSON Source