Skip to content

Commit 7f986dc

Browse files
georginahalpernGeorgina
andauthored
Update GUI control to be forgiving of text resizeToFit layout calculations (#16997)
Control.ts expects less than 3 layouts to occur but textBlock.ts will layout 3 times when resizeToFit is true -- this is because isDirty is set to true causing a recreation of fontOffset (even if font offset has the proper height) and thus fontOffset.height is getting recalculated to the old value We should fix the logic so that fontOffset retains the updated height value. Until then, upping the layout cycle detection error threshold Relayout 1: NewHeight 106, InternalHeight 187 --> updates internal height to be new height unnecessarily since the internalheight is valid Relayout 2: NewHeight 187, InternalHeight 106 Relayout 3: Both 187 --> exit loop (but at this point we're already at 3) <img width="236" height="39" alt="image" src="https://github.com/user-attachments/assets/2e2508c5-377e-42d1-be79-0a3d15d50529" /> See https://forum.babylonjs.com/t/jumping-text-with-resizetofit-false/59949 for more details --------- Co-authored-by: Georgina <[email protected]>
1 parent a28a2e7 commit 7f986dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/dev/gui/src/2D/controls/control.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,9 +1923,9 @@ export class Control implements IAnimatable, IFocusableControl {
19231923
this._rebuildLayout = false;
19241924
this._processMeasures(parentMeasure, context);
19251925
rebuildCount++;
1926-
} while (this._rebuildLayout && rebuildCount < 3);
1926+
} while (this._rebuildLayout && rebuildCount < 4);
19271927

1928-
if (rebuildCount >= 3) {
1928+
if (rebuildCount >= 4) {
19291929
Logger.Error(`Layout cycle detected in GUI (Control name=${this.name}, uniqueId=${this.uniqueId})`);
19301930
}
19311931

0 commit comments

Comments
 (0)