mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fixed with another approach.
This commit is contained in:
@@ -551,8 +551,8 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
}
|
||||
}
|
||||
|
||||
public test_SettingTextWhenInFixedSizeGridShouldRequestLayout() {
|
||||
this.requestLayoutFixture(true, "", () => {
|
||||
public test_SettingTextWhenInFixedSizeGridShouldNotRequestLayout() {
|
||||
this.requestLayoutFixture(false, "", () => {
|
||||
let host = new GridLayout();
|
||||
host.width = 100;
|
||||
host.height = 100;
|
||||
@@ -569,8 +569,8 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
});
|
||||
}
|
||||
|
||||
public test_SettingTextWhenFixedWidthAndHeightDoesRequestLayout() {
|
||||
this.requestLayoutFixture(true, "", label => {
|
||||
public test_SettingTextWhenFixedWidthAndHeightDoesNotRequestLayout() {
|
||||
this.requestLayoutFixture(false, "", label => {
|
||||
let host = new StackLayout();
|
||||
label.width = 100;
|
||||
label.height = 100;
|
||||
|
||||
@@ -45,15 +45,13 @@ export class Label extends common.Label {
|
||||
}
|
||||
|
||||
_requestLayoutOnTextChanged(): void {
|
||||
console.log("requestLayout called --------------------------------------->");
|
||||
if (this._fixedSize === FixedSize.BOTH) {
|
||||
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.
|
||||
return;
|
||||
}
|
||||
console.log("actual requestLayout called --------------------------------------->");
|
||||
super._requestLayoutOnTextChanged();
|
||||
}
|
||||
|
||||
@@ -74,13 +72,13 @@ export class Label extends common.Label {
|
||||
height = Number.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
if (this.text !== "") {
|
||||
//if (this.text !== "") {
|
||||
this._fixedSize = (widthMode === utils.layout.EXACTLY ? FixedSize.WIDTH : FixedSize.NONE)
|
||||
| (heightMode === utils.layout.EXACTLY ? FixedSize.HEIGHT : FixedSize.NONE);
|
||||
}
|
||||
else {
|
||||
this._fixedSize = FixedSize.NONE;
|
||||
}
|
||||
//}
|
||||
//else {
|
||||
// this._fixedSize = FixedSize.NONE;
|
||||
//}
|
||||
|
||||
var nativeSize = nativeView.sizeThatFits(CGSizeMake(width, height));
|
||||
var labelWidth = nativeSize.width;
|
||||
|
||||
Reference in New Issue
Block a user