[TIMOB-26183] Android: TextField 'change' event does not get fired if we change TextField.value from a Button 'click’.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | None |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2018-07-09T22:19:18.000+0000 |
Affected Version/s | Release 7.1.1 |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Mostafizur Rahman |
Assignee | Mostafizur Rahman |
Created | 2018-07-05T10:13:48.000+0000 |
Updated | 2018-07-09T22:19:18.000+0000 |
Description
*Issue Description:*
Textfield *’change'* event does not get fired if you change TextField.value from a Button 'click' callback. If we manually change textfield value then the change event fires.
*Test Environment:*
Appcelerator Command-Line Interface, version 7.0.4
Copyright (c) 2014-2018, Appcelerator, Inc. All Rights Reserved.
Operating System
Name = Mac OS X
Version = 10.13.5
Architecture = 64bit
# CPUs = 4
Memory = 8.0GB
Node.js
Node.js Version = 8.9.1
npm Version = 5.5.1
Appcelerator CLI
Installer = 4.2.13
Core Package = 7.0.4
Titanium CLI
CLI Version = 5.1.1
node-appc Version = 0.2.44
TI SDK 7.1.1.GA
Device details: Huawei Y9 2018 (android 8)
*Steps to reproduce:*
1. Run the test code
2. Click “Change text” button.
3. Observe that the log does not show the change event
4. Now try to change textfield value manually, observe the log and check that the change event fires successfully
*Test code:*
var win = Ti.UI.createWindow({
});
var txt = Ti.UI.createTextField({
enabled: true,
hintText: 'change me',
top: 10
});
txt.addEventListener('change', function(e) {
Ti.API.info('text changed');
});
var btn = Ti.UI.createButton({
bottom: 0,
title: 'Change Text'
});
btn.addEventListener('click', function(e) {
txt.value = 'Yay, text changed!';
});
win.add(txt);
win.add(btn);
win.open();
*Test Result:*
*Console logs:*
INFO] text changed
[INFO] text changed
[INFO] text changed
[INFO] text changed
[INFO] text changed
[WARN] InputMethodManager: startInputReason = 8
[WARN] IInputConnectionWrapper: getExtractedText on inactive InputConnection
[WARN] IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
[INFO] HwSecImmHelper: mSecurityInputMethodService is null
[WARN] IInputConnectionWrapper: getExtractedText on inactive InputConnection
[WARN] IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
[WARN] libEGL: EGLNativeWindowType 0x74aa060010 disconnect failed
[INFO] APSAnalyticsService: Analytics Service Started
[INFO] APSAnalyticsService: Stopping Analytics Service
This is not a bug. This is the intended behavior. Please see ticket: [TIMOB-17210] Before Titanium 7.1.0, this was the behavior on Android, but not the behavior on iOS or Windows. The community expected Android to match iOS' behavior where changing a TextField/TextArea's text programmatically would NOT fire a "change" event. Android was modified to match this behavior in 7.1.0. If your app requires the old behavior, then you can fire the "change" event manually from button "click" event handler as follows...