@@ -68,11 +68,25 @@ export class Label extends TextBase implements LabelDefinition {
6868 this . _fixedSize = ( widthMode === layout . EXACTLY ? FixedSize . WIDTH : FixedSize . NONE )
6969 | ( heightMode === layout . EXACTLY ? FixedSize . HEIGHT : FixedSize . NONE ) ;
7070
71- // NOTE: utils.measureNativeView(...) relies on UIView.sizeThatFits(...) that
72- // seems to have various issues when laying out UILabel instances.
73- // We use custom measure logic here that relies on overriden
74- // UILabel.textRectForBounds:limitedToNumberOfLines: in TNSLabel widget.
75- const nativeSize = this . _measureNativeView ( width , widthMode , height , heightMode ) ;
71+ let nativeSize ;
72+ if ( this . textWrap ) {
73+ // https://github.com/NativeScript/NativeScript/issues/4834
74+ // NOTE: utils.measureNativeView(...) relies on UIView.sizeThatFits(...) that
75+ // seems to have various issues when laying out UILabel instances.
76+ // We use custom measure logic here that relies on overriden
77+ // UILabel.textRectForBounds:limitedToNumberOfLines: in TNSLabel widget.
78+ nativeSize = this . _measureNativeView ( width , widthMode , height , heightMode ) ;
79+ } else {
80+ // https://github.com/NativeScript/NativeScript/issues/6059
81+ // NOTE: _measureNativeView override breaks a scenario with StackLayout that arranges
82+ // labels horizontally (with textWrap=false) e.g. we are measuring label #2 within 356px,
83+ // label #2 needs more, and decides to show ellipsis(...) but because of this its native size
84+ // returned from UILabel.textRectForBounds:limitedToNumberOfLines: logic becomes 344px, so
85+ // StackLayout tries to measure label #3 within the remaining 12px which is wrong;
86+ // label #2 with ellipsis should take the whole 356px and label #3 should not be visible at all.
87+ nativeSize = layout . measureNativeView ( nativeView , width , widthMode , height , heightMode ) ;
88+ }
89+
7690 let labelWidth = nativeSize . width ;
7791
7892 if ( this . textWrap && widthMode === layout . AT_MOST ) {
0 commit comments