Fixed with another approach.

This commit is contained in:
Nedyalko Nikolov
2016-08-16 17:02:57 +03:00
parent 97a1ad6a7a
commit dc5b7d5bac
2 changed files with 10 additions and 12 deletions

View File

@@ -551,8 +551,8 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
} }
} }
public test_SettingTextWhenInFixedSizeGridShouldRequestLayout() { public test_SettingTextWhenInFixedSizeGridShouldNotRequestLayout() {
this.requestLayoutFixture(true, "", () => { this.requestLayoutFixture(false, "", () => {
let host = new GridLayout(); let host = new GridLayout();
host.width = 100; host.width = 100;
host.height = 100; host.height = 100;
@@ -569,8 +569,8 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
}); });
} }
public test_SettingTextWhenFixedWidthAndHeightDoesRequestLayout() { public test_SettingTextWhenFixedWidthAndHeightDoesNotRequestLayout() {
this.requestLayoutFixture(true, "", label => { this.requestLayoutFixture(false, "", label => {
let host = new StackLayout(); let host = new StackLayout();
label.width = 100; label.width = 100;
label.height = 100; label.height = 100;

View File

@@ -45,15 +45,13 @@ export class Label extends common.Label {
} }
_requestLayoutOnTextChanged(): void { _requestLayoutOnTextChanged(): void {
console.log("requestLayout called --------------------------------------->");
if (this._fixedSize === FixedSize.BOTH) { if (this._fixedSize === FixedSize.BOTH) {
return; return;
} }
if (this._fixedSize === FixedSize.WIDTH && !this.textWrap) { if (this._fixedSize === FixedSize.WIDTH && !this.textWrap && this.getMeasuredHeight() > 0) {
// Single line label with fixed width will skip request layout on text change. // Single line label with fixed width will skip request layout on text change.
return; return;
} }
console.log("actual requestLayout called --------------------------------------->");
super._requestLayoutOnTextChanged(); super._requestLayoutOnTextChanged();
} }
@@ -74,13 +72,13 @@ export class Label extends common.Label {
height = Number.POSITIVE_INFINITY; height = Number.POSITIVE_INFINITY;
} }
if (this.text !== "") { //if (this.text !== "") {
this._fixedSize = (widthMode === utils.layout.EXACTLY ? FixedSize.WIDTH : FixedSize.NONE) this._fixedSize = (widthMode === utils.layout.EXACTLY ? FixedSize.WIDTH : FixedSize.NONE)
| (heightMode === utils.layout.EXACTLY ? FixedSize.HEIGHT : FixedSize.NONE); | (heightMode === utils.layout.EXACTLY ? FixedSize.HEIGHT : FixedSize.NONE);
} //}
else { //else {
this._fixedSize = FixedSize.NONE; // this._fixedSize = FixedSize.NONE;
} //}
var nativeSize = nativeView.sizeThatFits(CGSizeMake(width, height)); var nativeSize = nativeView.sizeThatFits(CGSizeMake(width, height));
var labelWidth = nativeSize.width; var labelWidth = nativeSize.width;