From 5003e0bb3a9d33fa91b7b99611dfc9510500a6f3 Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Tue, 6 Aug 2024 12:35:40 -0600 Subject: [PATCH] Add reentrant: true, see https://github.com/phetsims/density-buoyancy-common/issues/268 --- js/common/model/Material.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/common/model/Material.ts b/js/common/model/Material.ts index 487f1de2..c430b8c4 100644 --- a/js/common/model/Material.ts +++ b/js/common/model/Material.ts @@ -87,13 +87,18 @@ export default class Material extends PhetioObject implements MappedWrappedObjec phetioDocumentation: 'Density of the material', phetioReadOnly: !( providedOptions.hidden || providedOptions.custom ), // Read-only unless it's a mystery or custom material rangePropertyOptions: { + // When used in a MaterialControlNode, the component will override the rangeProperty, even when the sim is reset // This is done in a recursive/reentrant link call, so we need to ensure that the value comparison is an equals function reentrant: true, valueComparisonStrategy: 'equalsFunction' }, range: new Range( 0.8, 27000 ), - units: 'kg/m^3' + units: 'kg/m^3', + + // Like the rangeProperty above, in MaterialControlNode, when syncCustomMaterialDensity is true, MaterialControlNode + // overrides the density value to keep it in range when material changes. + reentrant: true }, viscosity: 1e-3, custom: false,