{ "id": "168535", "key": "TIMOB-24866", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "17609", "description": "", "name": "Release 7.0.0", "archived": false, "released": true, "releaseDate": "2017-12-07" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2017-11-15T04:31:52.000+0000", "created": "2017-06-20T21:56:27.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "textfield" ], "versions": [ { "id": "18928", "name": "Release 6.0.2", "archived": false, "released": true, "releaseDate": "2017-02-27" } ], "issuelinks": [ { "id": "55258", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "168389", "key": "AC-5025", "fields": { "summary": " textAlign: Ti.UI.TEXT_ALIGNMENT_RIGHT not working", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-11-15T06:46:51.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "*Summary:*\r\nSetting the padding on a TextField wrongly resets its horizontal \"textAlign\" and \"verticalAlign\" properties to left and center respectively.\r\n\r\n*Steps to reproduce:*\r\n# Build and run the below code on Android.\r\n# Tap the \"Set Padding\" button.\r\n# Notice that the text alignment of the 3 fields change to left/center.\r\n\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow({ layout: \"vertical\" });\r\n\r\nvar textField1 = Ti.UI.createTextField(\r\n{\r\n\tvalue: \"Top-Left Aligned Text\",\r\n\ttextAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,\r\n\tverticalAlign: Ti.UI.TEXT_VERTICAL_ALIGNMENT_TOP,\r\n\tbackgroundColor: \"black\",\r\n\twidth: \"90%\",\r\n\theight: \"20%\",\r\n\ttop: \"5%\",\r\n});\r\nwindow.add(textField1);\r\n\r\nvar textField2 = Ti.UI.createTextField(\r\n{\r\n\tvalue: \"Centered Text\",\r\n\ttextAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,\r\n\tverticalAlign: Ti.UI.TEXT_VERTICAL_ALIGNMENT_CENTER,\r\n\tbackgroundColor: \"black\",\r\n\twidth: \"90%\",\r\n\theight: \"20%\",\r\n\ttop: \"5%\",\r\n});\r\nwindow.add(textField2);\r\n\r\nvar textField3 = Ti.UI.createTextField(\r\n{\r\n\tvalue: \"Bottom-Right Aligned Text\",\r\n\ttextAlign: Ti.UI.TEXT_ALIGNMENT_RIGHT,\r\n\tverticalAlign: Ti.UI.TEXT_VERTICAL_ALIGNMENT_BOTTOM,\r\n\tbackgroundColor: \"black\",\r\n\twidth: \"90%\",\r\n\theight: \"20%\",\r\n\ttop: \"5%\",\r\n});\r\nwindow.add(textField3);\r\n\r\nvar button = Ti.UI.createButton(\r\n{\r\n\ttitle: \"Set Padding\",\r\n\ttop: \"5%\",\r\n});\r\nbutton.addEventListener(\"click\", function(e)\r\n{\r\n\tvar padding = { top: 5, left: 5, bottom: 5, right: 5 };\r\n\ttextField1.padding = padding;\r\n\ttextField2.padding = padding;\r\n\ttextField3.padding = padding;\r\n});\r\nwindow.add(button);\r\n\r\nwindow.open();\r\n{code}\r\n\r\n*Expected Result:*\r\nConfigured alignment should not change.\r\n\r\n*Work-Around:*\r\nDevelopers can work-around this issue by setting the \"textAlignment\" and \"verticalAlignment\" properties after setting the \"padding\" property.\r\n\r\n*Cause:*\r\nThe Java TiUIText.setTextPadding() method is resetting the field's gravity to CENTER_VERTICAL when it shouldn't.\r\nhttps://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIText.java#L233\r\n", "attachment": [ { "id": "62714", "filename": "After.png", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-06-21T03:29:21.000+0000", "size": 29925, "mimeType": "image/png" }, { "id": "62715", "filename": "Before.png", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-06-21T03:29:21.000+0000", "size": 30030, "mimeType": "image/png" }, { "id": "63006", "filename": "Screen Shot 2017-08-08 at 3.43.24 PM.png", "author": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-08-08T22:45:02.000+0000", "size": 30420, "mimeType": "image/png" } ], "flagged": false, "summary": "Android: Setting a TextField's \"padding\" resets its alignment to left/center", "creator": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "closedSprints": [ { "id": 963, "state": "closed", "name": "2017 Sprint 22 SDK", "startDate": "2017-10-22T21:43:59.523Z", "endDate": "2017-11-05T22:43:00.000Z", "completeDate": "2017-11-06T16:33:42.425Z", "originBoardId": 114 }, { "id": 948, "state": "closed", "name": "2017 Sprint 19 SDK", "startDate": "2017-09-10T21:24:51.562Z", "endDate": "2017-09-24T21:24:00.000Z", "completeDate": "2017-09-25T17:49:27.460Z", "originBoardId": 114 }, { "id": 951, "state": "closed", "name": "2017 Sprint 20 SDK", "startDate": "2017-09-24T17:50:18.277Z", "endDate": "2017-10-08T17:50:00.000Z", "completeDate": "2017-10-09T20:38:07.840Z", "originBoardId": 114 }, { "id": 968, "state": "closed", "name": "2017 Sprint 23 SDK", "startDate": "2017-11-05T16:37:25.071Z", "endDate": "2017-11-19T16:37:00.000Z", "completeDate": "2017-11-20T18:57:56.565Z", "originBoardId": 114 }, { "id": 939, "state": "closed", "name": "2017 Sprint 17 SDK", "startDate": "2017-08-13T23:08:29.095Z", "endDate": "2017-08-27T23:08:00.000Z", "completeDate": "2017-08-27T21:10:54.125Z", "originBoardId": 114 }, { "id": 959, "state": "closed", "name": "2017 Sprint 21 SDK", "startDate": "2017-10-08T20:38:15.130Z", "endDate": "2017-10-22T20:38:00.000Z", "completeDate": "2017-10-24T23:55:56.605Z", "originBoardId": 114 }, { "id": 944, "state": "closed", "name": "2017 Sprint 18 SDK", "startDate": "2017-08-27T21:13:39.311Z", "endDate": "2017-09-10T21:13:00.000Z", "completeDate": "2017-09-10T21:24:16.435Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "424676", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR\r\n* 6_2_x: https://github.com/appcelerator/titanium_mobile/pull/9247\r\n* Master: https://github.com/appcelerator/titanium_mobile/pull/9248", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-07-25T18:24:20.000+0000", "updated": "2017-07-25T18:28:00.000+0000" }, { "id": "426298", "author": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~michael] [~jquick] I am able to verify fix in SDK Version: 6.2.0.v20170808135421 and 7.0.0.v20170801134317 but on the newest build (7.0.0.v20170801134317) I am unable to verify. \r\n\r\nAs you can see text is not correctly aligned: \r\n !Screen Shot 2017-08-08 at 3.43.24 PM.png|thumbnail! \r\n\r\n*Environment*\r\n{code:java}\r\nAppcelerator Command-Line Interface, version 6.2.3-21\r\nGoogle nexus 6P 7.0.0 Emulator \r\nOperating System Name: Mac OS X El Capitan\r\nOperating System Version: 10.11.6\r\nNode.js Version: 6.10.1\r\nXcode: 8.2\r\nAppcelerator Studio: 4.9.0.201705302345\r\n{code}\r\n", "updateAuthor": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-08-08T22:28:29.000+0000", "updated": "2017-08-08T22:46:27.000+0000" }, { "id": "426303", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~smohammed], this bug is technically fixed. So, let's merge and close it anyways.\r\n\r\nWhat you're seeing now is a new issue that was accidentally introduced by this PR...\r\n https://github.com/appcelerator/titanium_mobile/pull/9114\r\n\r\nIn Titanium 7.0, TextField has been switched over to use Google's new/modern \"TextInputLayout\" which is capable of showing \"hint\" text above the input field (currently supported) and error/helper text below the input field (not supported yet).\r\n https://material.io/guidelines/components/text-fields.html#text-fields-layout\r\n\r\nUnfortunately, with the way it works now, the \"height\" property is applied to the TextInputLayout as a whole instead of the \"EditText\" input field in the middle like how it used to work. So, now there is a lot of empty space below the input field where the error/helper text is supposed to go. This also makes our \"verticalAlign\" property effectively useless. This is a breaking change, although to be fair, I would hope most developers would not hard code a height value (like the above sample project) since they run the risk of the font being clipped if too small or the field being ridiculously large compared to the font. (This is Google's expectation.)\r\n\r\n[~gmathews], I'm not quite sure what we should do about this. I have confirmed that setting the vertical layout parameter to MATCH_PARENT instead of WRAP_CONTENT resolves this issue when adding the EditText to the TextInputLayout.\r\n\r\n{code:java}\r\ntextInputLayout.addView(tv, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));\r\n{code}\r\n\r\nBut the above will prevent the bottom error/helper text from being shown (we don't support this yet, but we may want to in the future). Plus doing the above goes against what Google recommends (possible future breakage). Applying a \"weight\" value to the EditText's layout parameters to have it fill the middle doesn't work either (I've tried). I'm now wondering if a better solution is to have the developer opt-in to the TextInputLayout behavior upon construction Ti.UI.createTextField() instead of always applying it. Hmm... any thoughts on this?\r\n\r\n*Side Note:*\r\n[~gmathews], there is a new \"padding\" bug on (master) that you can see when running this case's test project. The Java TiUIText.setPadding() is applying padding to the EditText (ie: the \"tv\" member variable) when it should be applied to the TextInputLayout instead. Doing this will make the field's bottom line line-up with the EditText above it and prevent them from overlapping if padding is set to zero.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-08-09T02:41:01.000+0000", "updated": "2017-08-09T02:41:01.000+0000" }, { "id": "426322", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~jquick] I think for the time being we should implement the workaround you found, setting the vertical layout parameter to MATCH_PARENT and create a ticket for this issue. Since this will maintain our expected behaviour until we figure out a better fix and we can discuss ideas in the new ticket.", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-08-09T13:07:33.000+0000", "updated": "2017-08-09T13:07:33.000+0000" }, { "id": "427293", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "master: https://github.com/appcelerator/titanium_mobile/pull/9361", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-08-28T00:08:35.000+0000", "updated": "2017-08-28T00:08:35.000+0000" }, { "id": "430552", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "FR Passed.\r\nWaiting for merge to get enabled.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-11-13T22:50:00.000+0000", "updated": "2017-11-13T22:50:00.000+0000" }, { "id": "430677", "author": { "name": "amukherjee", "key": "amukherjee", "displayName": "Abir Mukherjee", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Changes are seen in SDK 7.0.0.v20171114202841.", "updateAuthor": { "name": "amukherjee", "key": "amukherjee", "displayName": "Abir Mukherjee", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-11-15T06:46:51.000+0000", "updated": "2017-11-15T06:46:51.000+0000" } ], "maxResults": 12, "total": 12, "startAt": 0 } } }