Closed pixelzoom closed 6 months ago
Relevant code is in IdealLawGasModel.ts. Adding a debugger indicates that this.container.lidIsOpenProperty.value
is true
.
this.container.lidIsOpenProperty.link( lidIsOpen => {
if ( !isSettingPhetioStateProperty.value ) {
if ( lidIsOpen && this.holdConstantProperty.value === 'temperature' ) {
phet.log && phet.log( 'Oops! T cannot be held constant when the container is open' );
this.holdConstantProperty.value = 'nothing';
+ debugger;
this.oopsEmitters.temperatureLidOpenEmitter.emit();
}
}
} );
lidIsOpenProperty
is derived in IdealGasLawContainer.ts:
this.lidIsOpenProperty = new DerivedProperty(
// this.widthProperty is used by this.getMaxLidWidth()
[ this.lidIsOnProperty, this.lidWidthProperty, this.widthProperty ],
( lidIsOn, lidWidth, containerWidth ) => !lidIsOn || ( lidWidth < this.getMaxLidWidth() ), {
tandem: options.tandem.createTandem( 'lidIsOpenProperty' ),
phetioFeatured: true,
phetioValueType: BooleanIO,
phetioDocumentation: 'Whether the container\'s lid is open.'
} );
Inspecting the dependencies:
lidIsOn => true lidWidth => 8075 getMaxLidWidth() => ~8083
So the lid is on, but the lid's width does not cover the opening in the top of the container.
I'm guessing that this is a problem with listener order. There's probably something that adjusts lidWidthProperty
that has not executed yet.
The problem is indicated by the comment here:
this.lidIsOpenProperty = new DerivedProperty(
// this.widthProperty is used by this.getMaxLidWidth()
[ this.lidIsOnProperty, this.lidWidthProperty, this.widthProperty ],
getMaxLidWidth
uses widthProperty
. So a dependency on widthProperty
was added to appease axon's strictAxonDependencies
option. But widthProperty
is updated before lidWidthProperty
, and that results in an internmediate state where the container is slightly open.
To resolve this problem in https://github.com/phetsims/gas-properties/commit/eeb0632b7bda8ff340f7c7fda9f60645d3b9e42e, I removed the dependency on widthProperty
and added:
strictAxonDependencies: false, // See https://github.com/phetsims/gas-properties/issues/246
The problem is not longer reproducible, so closing.
Noticed during 5/202/24 design meeting.
Steps to reproduce: