phetsims / equality-explorer

"Equality Explorer" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
2 stars 3 forks source link

Dynamic layout problem with lefthand side of equations. #211

Open pixelzoom opened 2 hours ago

pixelzoom commented 2 hours ago

Related to https://github.com/phetsims/equality-explorer/issues/187 ...

There's a dynamic layout problem with the equations (EquationNode) in the Solve It! screen, reproducible with ?stringTest=dynamic. For example:

screenshot_3603

I thought the patch below would resolve the problem, but it results in a new layout problem:

patch ```diff Subject: [PATCH] set maxWidth and minContentWidth for SnapshotsAccordionBox content, https://github.com/phetsims/equality-explorer/issues/207 --- Index: js/common/view/EquationNode.ts IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/view/EquationNode.ts b/js/common/view/EquationNode.ts --- a/js/common/view/EquationNode.ts (revision e5daa6801b1324a001c6ca82dcbee4d48d33ae99) +++ b/js/common/view/EquationNode.ts (date 1731857148487) @@ -163,7 +163,8 @@ this.leftExpressionNode = new ExpressionNode( this.leftTermCreators, this.expressionNodeOptions ); this.rightExpressionNode = new ExpressionNode( this.rightTermCreators, this.expressionNodeOptions ); this.children = [ this.leftExpressionNode, this.relationalOperatorText, this.rightExpressionNode ]; - this.updateLayout(); + Multilink.multilink( [ this.leftExpressionNode.localBoundsProperty, this.rightExpressionNode.localBoundsProperty ], + () => this.updateLayout() ); } /** @@ -171,7 +172,7 @@ */ private updateRelationalOperator(): void { this.relationalOperatorText.string = getRelationalOperator( this.leftTermCreators, this.rightTermCreators ); - this.updateLayout(); + this.relationalOperatorText.localBoundsProperty.link( () => this.updateLayout() ); } /** ```
screenshot_3601
pixelzoom commented 2 hours ago

This is a problem anywhere that a dynamic string appears on the lefthand side of the equation. For example, in the Variables screen:

screenshot_3604