[TIMOB-23501] iOS: Ti.UI.Label.ellipsize should default to Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_END, but is undefined
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-08-24T23:28:01.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.0.0 |
Components | iOS |
Labels | parity, qe-6.0.0 |
Reporter | Christopher Williams |
Assignee | Angel Petkov |
Created | 2016-06-10T19:52:52.000+0000 |
Updated | 2016-10-05T13:50:52.000+0000 |
Description
According to docs, it should default to false. See https://github.com/appcelerator/titanium-mobile-mocha-suite/blob/master/Resources/ti.ui.label.test.js#L95 for the unit test, but here's the snippet:
it('ellipsize', function () {
var label = Ti.UI.createLabel({
text: 'this is some text'
});
should(label.ellipsize).be.a.Boolean; // undefined on iOS
should(label.getEllipsize).be.a.Function;
should(label.ellipsize).eql(false);
should(label.getEllipsize()).eql(false);
label.ellipsize = true;
should(label.getEllipsize()).eql(true);
should(label.ellipsize).eql(true);
});
The ellipsize property isn't actually a boolean we just allow booleans to be passed in for parity with android(or atleast thats what it says in the code) as they have different constants. For iOS the default is NSLineBreakByTruncatingTail, we are actually setting this [property](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UILabel_Class/#//apple_ref/occ/instp/UILabel/lineBreakMode). On iOS its returning null because its never set through the proxy so the proxy doesn't contain any value, if you were to grab any property out that label for example the height it will also return null/nil.
My 2 cents: As we can only set Number-constants, I wonder why Android could even return false in any case. So we should return the
Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_END
in both platforms by default.PR:https://github.com/appcelerator/titanium_mobile/pull/8086 * Updated the Docs * Will return Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_END (4) by default for IOS * Added 3 new constants that are iOS as we already have one constant thats android only. Android doesn't have a default value set for the ellipsis property.We need to change it to default to Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_END Demo code:
PR approved! Additional test-code for unit-testing:
[~cwilliams] We now use
Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_END
by default on both platforms, making Android looking better by default as well. We left the boolean-check for legacy-purposes and ultimately need to update the unit tests. See my above comment regarding default-values. Thanks![~apetkov] So. Ti.UI.Label.ellipsize should return a constant in both android and iOS. there's no true / false going on anymore. However, I just ran a unit test on it and realised that
label.ellipsize
doesn't return a number. Can you investigate?Expected Result
label.ellipsize should return a default number. Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_END.Note to QE: description was based on this property being true/false. but it's actually a number so check for number.
Removing parameter from proxy getter method fixed issue. * PR: https://github.com/appcelerator/titanium_mobile/pull/8255 * PR (6.0.X): https://github.com/appcelerator/titanium_mobile/pull/8256
[~cng] Updated your example code to: - Make
wordwrap
Android-only in your test-case (since it is) - Do a logical comparison to check if the default-value matches the docs (it does) [~apetkov] iOS works great, can you verify Android as well? I'll merge afterwards.[~hansknoechel] Im still getting undefined for wordWrap on android. Added a 6.0.0 backport in the comment above, once android is resolved.
Verified as fixed,
label.ellipsize
returns a default numerical value, and is no longer undefined. Tested On: iPhone 6 Plus 10.0.2 Device iPhone 5S 9.3.5 Device Mac OSX El Capitan 10.11.6 Ti SDK: 6.0.0.v20161004202820 Appc Studio: 4.8.0.201609292239 Appc NPM: 4.2.8-7 App CLI: 6.0.0-56 Xcode 8.0 Node v4.4.7 *Closing ticket.*