Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23501] iOS: Ti.UI.Label.ellipsize should default to Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_END, but is undefined

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-08-24T23:28:01.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.0.0
ComponentsiOS
Labelsparity, qe-6.0.0
ReporterChristopher Williams
AssigneeAngel Petkov
Created2016-06-10T19:52:52.000+0000
Updated2016-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);
	});

Comments

  1. Angel Petkov 2016-06-14

    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.
  2. Hans Knöchel 2016-06-21

    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.
  3. Angel Petkov 2016-06-24

    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:
       
       var win = Ti.UI.createWindow({
         backgroundColor: 'white',
       });
       
       var label = Ti.UI.createLabel({
         color: '#900',
         text: 'Ellipsize',
         width: 100, 
         height: 100,
       });
       
       label.addEventListener("click",function(e){
       	Ti.API.info(label.getEllipsize());
       })
       win.add(label);
       win.open();
       
  4. Hans Knöchel 2016-06-29

    PR approved! Additional test-code for unit-testing:
       var label = Ti.UI.createLabel();
       
       Ti.API.warn(label.getEllipsize() == Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_END); // Should be "true"
       Ti.API.warn(label.getEllipsize() == Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_MIDDLE); // Should be "false"
       
       label.setEllipsize(Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_MIDDLE);
       
       Ti.API.warn(label.getEllipsize() == Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_MIDDLE); // Should be "true"
       Ti.API.warn(label.getEllipsize() == Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_END); // Should be "false"
       
  5. Hans Knöchel 2016-06-29

    [~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!
  6. Chee Kiat Ng 2016-08-24

    [~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?
       
       var win = Ti.UI.createWindow({
           backgroundColor: 'gray'
       });
        
       var label = Ti.UI.createLabel({
           text: 'this is some text'
       });
       
       // This is Android-only
       if (Ti.Platform.osname == "android") {
           Ti.API.info('wordwrap: ' + label.wordWrap);
       }
       
       // This is cross-platform
       Ti.API.info('ellipsize: ' + label.ellipsize);
       Ti.API.info("Default value correct? " + (label.ellipsize == Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_END));
       
       win.add(label);
       win.open();
       

    Expected Result

    label.ellipsize should return a default number. Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_END.
  7. Chee Kiat Ng 2016-08-24

    Note to QE: description was based on this property being true/false. but it's actually a number so check for number.
  8. Angel Petkov 2016-08-24

    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
  9. Hans Knöchel 2016-08-24

    [~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.
  10. Angel Petkov 2016-08-24

    [~hansknoechel] Im still getting undefined for wordWrap on android. Added a 6.0.0 backport in the comment above, once android is resolved.
  11. Chee Kiat Ng 2016-08-25

  12. Harry Bryant 2016-10-05

    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.*

JSON Source