[ALOY-1306] AttributedString proxy property doesn't work if there's whitespace
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | None |
| Status | Closed |
| Resolution | Cannot Reproduce |
| Resolution Date | 2017-02-24T01:12:20.000+0000 |
| Affected Version/s | Alloy 1.7.0 |
| Fix Version/s | n/a |
| Components | XML |
| Labels | n/a |
| Reporter | Fokke Zandbergen |
| Assignee | Bruce Wayne |
| Created | 2015-09-23T12:09:16.000+0000 |
| Updated | 2017-02-24T01:12:20.000+0000 |
Description
The
<AttributedString> described in the [docs](http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_XML_Markup-section-35621528_AlloyXMLMarkup-ProxyProperties) does not work if there's whitespace between the <Label> and <AttributedString> elements because of TIMOB-19168.
*XML*
<Alloy>
<Window>
<Label>
<AttributedString class="ATTRIBUTE_LINE_BREAK_BY_CHAR_WRAPPING">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam venenatis vel orci sit amet facilisis. Sed lobortis ante et sapien sagittis, eu mattis libero suscipit.</AttributedString>
</Label>
</Window>
</Alloy>
*TSS*
".ATTRIBUTE_LINE_BREAK_BY_CHAR_WRAPPING" : {
attributes: [
{
type: Ti.UI.ATTRIBUTE_LINE_BREAK,
value: Ti.UI.ATTRIBUTE_LINE_BREAK_BY_CHAR_WRAPPING,
range: [0, 164]
}
]
}
*compiled*
$.__views.__alloyId14 = Ti.UI.createAttributedString({
attributes: [ {
type: Ti.UI.ATTRIBUTE_LINE_BREAK,
value: Ti.UI.ATTRIBUTE_LINE_BREAK_BY_CHAR_WRAPPING,
range: [ 0, 164 ]
} ],
text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam venenatis vel orci sit amet facilisis. Sed lobortis ante et sapien sagittis, eu mattis libero suscipit.",
id: "__alloyId14"
});
$.__views.__alloyId13 = Ti.UI.createLabel({
font: {
fontSize: 17
},
text: "",
attributedString: $.__views.__alloyId14,
id: "__alloyId13"
});
As you can see the text property is set to "" which because of TIMOB-19168 results in an empty label. The workaround is to do:
<Alloy>
<Window>
<Label><AttributedString class="ATTRIBUTE_LINE_BREAK_BY_CHAR_WRAPPING">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam venenatis vel orci sit amet facilisis. Sed lobortis ante et sapien sagittis, eu mattis libero suscipit.</AttributedString></Label>
</Window>
</Alloy>
But Alloy should take care of this since it doesn't make sense to set a text and attributedString at the same time, in particular because of TIMOB-19168 and that all samples in the documentation include spacing.
I was also wondering why do we have 2 alternate (the other being ALOY-961) implementations for attributedStrings in Alloy?
Checking the [PR](https://github.com/appcelerator/alloy/pull/644/files) for ALOY-961 I see that the description of that ticket is not what was in the end implemented, but it *IS* what we have in the release notes: https://github.com/appcelerator/alloy/releases/tag/1.7.8 The documentation seems OK because that only speaks about the proxy property, but the release notes need to be fixed [~bhatfield]
alloy@1.9.8 *Compiled*
$.__views.__alloyId1 = Ti.UI.createAttributedString({ attributes: [ { type: Ti.UI.ATTRIBUTE_LINE_BREAK, value: Ti.UI.ATTRIBUTE_LINE_BREAK_BY_CHAR_WRAPPING, range: [ 0, 164 ] } ], text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam venenatis vel orci sit amet facilisis. Sed lobortis ante et sapien sagittis, eu mattis libero suscipit.", id: "__alloyId1" }); $.__views.__alloyId0 = Ti.UI.createLabel({ font: { fontSize: 15 }, attributedString: $.__views.__alloyId1, id: "__alloyId0" });