[TIMOB-13364] Android: TextArea maxLength not working in Android
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-10-02T21:00:33.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Carter Lathrop |
Assignee | Sunila |
Created | 2013-04-03T17:19:52.000+0000 |
Updated | 2017-03-16T22:29:30.000+0000 |
Description
According to the docs, TextArea supports maxLength property from SDK 3.0. However, maxLength does not work in Android.
In TiUIText.java, the code that reads the maxLength is:
if (d.containsKey(TiC.PROPERTY_MAX_LENGTH) && field) {
maxLength = TiConvert.toInt(d, TiC.PROPERTY_MAX_LENGTH);
}
TextArea has "field" boolean set to false, so maxLength is always ignored.
Steps to reproduce. Create simple App.js:
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});
var textArea = Ti.UI.createTextArea({
borderWidth: 2,
borderColor: '#bbb',
borderRadius: 5,
color: '#888',
textAlign: 'left',
maxLength: 10,
top: 60,
width: 300,
height : 150
});
win.add(textArea);
win.open();
Launch app and start writing in the text area. You can enter more than 10 chars, despite maxLength is set to 10. Tested with SDK 3.0.0.GA in Android 2.3.3 and Android 4.1
Javier, Would you please post a simple test case that shows this bug? Providing a test case for issues allows for a much quicker and smoother review and turnaround time. Once a valid test case is provided we can continue to process the bug. For reference: https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report Thank you for your assistance, Carter
Added test case. Regards
Tested and confirmed, maxLength is not working atm. Moved to Ti-Mobile. Carter
Issue reproduced in 3.1.0GA also
The issue is still going on with 3.3.0 GA. It is really an annoying problem for all the apps that allow to write tweets. I guess a solution would be to remove the condition on "field" in TiUIText.java : turn
into
Remove the check for textfield ('field') when setting maxLength as this is available to textArea also https://github.com/appcelerator/titanium_mobile/pull/6178
HI Ingo, I am facing the in MaxLength property in TextArea in android, And i am using 3.4.1.GA SDK . Issue is still open in android. So pls give some suggestion or solution so make it work for android
Closing ticket as fixed.