FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge pull request #2591 from NativeScript/nnikolov/LabelZeroHeigthIs… · NativeScript/NativeScript@a730529 · GitHub

Commit a730529

Browse files
Nedyalko Nikolov
authored
Merge pull request #2591 from NativeScript/nnikolov/LabelZeroHeigthIssueNew
Label zero height issue fixed.
2 parents 3968d6f + e28bdd8 commit a730529

2 files changed

Lines changed: 54 additions & 9 deletions

File tree

‎tests/app/ui/label/label-tests.ts‎

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,13 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
524524
TKUnit.assertNotEqual(this.errorMessage, undefined);
525525
}
526526

527-
private requestLayoutFixture(expectRequestLayout: boolean, setup: (label: Label) => LayoutBase): void {
527+
private requestLayoutFixture(expectRequestLayout: boolean, initialValue: string, setup: (label: Label) => LayoutBase): void {
528528
if (!isIOS) {
529529
return;
530530
}
531531

532532
let label = new Label();
533+
label.text = initialValue;
533534
let host = setup(label);
534535

535536
host.addChild(label);
@@ -540,7 +541,8 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
540541

541542
let called = false;
542543
label.requestLayout = () => called = true;
543-
label.text = "Hello World";
544+
// changing text actually could request layout
545+
label.text = initialValue + " Again";
544546

545547
if (expectRequestLayout) {
546548
TKUnit.assertTrue(called, "label.requestLayout should be called.");
@@ -550,7 +552,16 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
550552
}
551553

552554
public test_SettingTextWhenInFixedSizeGridShouldNotRequestLayout() {
553-
this.requestLayoutFixture(false, () => {
555+
this.requestLayoutFixture(false, "", () => {
556+
let host = new GridLayout();
557+
host.width = 100;
558+
host.height = 100;
559+
return host;
560+
});
561+
}
562+
563+
public test_ChangingTextWhenInFixedSizeGridShouldNotRequestLayout() {
564+
this.requestLayoutFixture(false, "Hello World", () => {
554565
let host = new GridLayout();
555566
host.width = 100;
556567
host.height = 100;
@@ -559,7 +570,16 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
559570
}
560571

561572
public test_SettingTextWhenFixedWidthAndHeightDoesNotRequestLayout() {
562-
this.requestLayoutFixture(false, label => {
573+
this.requestLayoutFixture(false, "", label => {
574+
let host = new StackLayout();
575+
label.width = 100;
576+
label.height = 100;
577+
return host;
578+
});
579+
};
580+
581+
public test_ChangingTextWhenFixedWidthAndHeightDoesNotRequestLayout() {
582+
this.requestLayoutFixture(false, "Hello World", label => {
563583
let host = new StackLayout();
564584
label.width = 100;
565585
label.height = 100;
@@ -568,23 +588,48 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
568588
};
569589

570590
public test_SettingTextWhenSizedToContentShouldInvalidate() {
571-
this.requestLayoutFixture(true, () => {
591+
this.requestLayoutFixture(true, "", () => {
572592
let host = new StackLayout();
573593
host.orientation = "horizontal";
574594
return host;
575595
});
576596
};
577597

578-
public test_SettingTextOnSingleLineTextWhenWidthIsSizedToParentAndHeightIsSizedToContentShouldNotRequestLayout() {
579-
this.requestLayoutFixture(false, () => {
598+
public test_ChangingTextWhenSizedToContentShouldInvalidate() {
599+
this.requestLayoutFixture(true, "Hello World", () => {
600+
let host = new StackLayout();
601+
host.orientation = "horizontal";
602+
return host;
603+
});
604+
};
605+
606+
public test_SettingTextOnSingleLineTextWhenWidthIsSizedToParentAndHeightIsSizedToContentShouldRequestLayout() {
607+
this.requestLayoutFixture(true, "", () => {
608+
let host = new StackLayout();
609+
host.width = 100;
610+
return host;
611+
});
612+
}
613+
614+
public test_ChangingTextOnSingleLineTextWhenWidthIsSizedToParentAndHeightIsSizedToContentShouldNotRequestLayout() {
615+
this.requestLayoutFixture(false, "Hello World", () => {
580616
let host = new StackLayout();
581617
host.width = 100;
582618
return host;
583619
});
584620
}
585621

586622
public test_SettingTextOnMultilineLineTextWhenWidthIsSizedToParentAndHeightIsSizedToContentShouldRequestLayout() {
587-
this.requestLayoutFixture(true, label => {
623+
this.requestLayoutFixture(true, "", label => {
624+
label.textWrap = true;
625+
let host = new StackLayout();
626+
host.width = 100;
627+
return host;
628+
});
629+
}
630+
631+
public test_ChangingTextOnMultilineLineTextWhenWidthIsSizedToParentAndHeightIsSizedToContentShouldRequestLayout() {
632+
this.requestLayoutFixture(true, "Hello World", label => {
588633
label.textWrap = true;
589634
let host = new StackLayout();
590635
host.width = 100;

‎tns-core-modules/ui/label/label.ios.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class Label extends common.Label {
4848
if (this._fixedSize === FixedSize.BOTH) {
4949
return;
5050
}
51-
if (this._fixedSize === FixedSize.WIDTH && !this.textWrap) {
51+
if (this._fixedSize === FixedSize.WIDTH && !this.textWrap && this.getMeasuredHeight() > 0) {
5252
// Single line label with fixed width will skip request layout on text change.
5353
return;
5454
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL