Skip to content

Commit

Permalink
reset the expandedProperty, phetsims/buoyancy#150
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kauzmann <[email protected]>
  • Loading branch information
zepumph committed May 14, 2024
1 parent b983ad2 commit 50bb056
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions js/buoyancy/view/BuoyancyLabScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ export default class BuoyancyLabScreenView extends DensityBuoyancyScreenView<Buo
tandem: fluidDisplacedAccordionBoxTandem
} );

this.resetEmitter.addListener( () => fluidDisplacedAccordionBox.expandedProperty.reset() );

const leftSideVBox = new VBox( {
align: 'left',
spacing: 5,
Expand Down
5 changes: 5 additions & 0 deletions js/common/view/DensityBuoyancyScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import DuckView from '../../buoyancy/view/DuckView.js';
import NumberIO from '../../../../tandem/js/types/NumberIO.js';
import Utils from '../../../../dot/js/Utils.js';
import createObservableArray, { ObservableArray } from '../../../../axon/js/createObservableArray.js';
import Emitter from '../../../../axon/js/Emitter.js';

// constants
const MARGIN = DensityBuoyancyCommonConstants.MARGIN;
Expand Down Expand Up @@ -114,6 +115,9 @@ export default class DensityBuoyancyScreenView<Model extends DensityBuoyancyMode
// TODO: PhET-iO instrument for https://github.com/phetsims/density-buoyancy-common/issues/82
protected waterLevelVolumeProperty: TReadOnlyProperty<number>;

// Called upon resetting
protected readonly resetEmitter = new Emitter();

public constructor( model: Model, providedOptions: SelfOptions ) {

const scaleIncrease = 3.5;
Expand Down Expand Up @@ -574,6 +578,7 @@ export default class DensityBuoyancyScreenView<Model extends DensityBuoyancyMode
listener: () => {
this.interruptSubtreeInput();
model.reset();
this.resetEmitter.emit();
},
tandem: tandem.createTandem( 'resetAllButton' )
} );
Expand Down

0 comments on commit 50bb056

Please sign in to comment.