Skip to content

Commit

Permalink
reuse SpectrumWindowDialog because hide no longer disposes, see phets…
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Apr 21, 2021
1 parent 355f934 commit 1a65f19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 7 additions & 1 deletion js/moleculesandlight/view/MoleculesAndLightScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ define( function( require ) {
// @private
var spectrumDiagram = new SpectrumDiagram( tandem.createTandem( 'spectrumDiagram' ) );

// the spectrum dialog, created lazily because Dialog requires sim bounds during construction
var dialog = null;

// Add the button for displaying the electromagnetic spectrum. Scale down the button content when it gets too
// large. This is done to support translations. Max width of this button is the width of the molecule control
// panel minus twice the default x margin of a rectangular push button.
Expand All @@ -149,7 +152,10 @@ define( function( require ) {
touchAreaXDilation: 7,
touchAreaYDilation: 7,
listener: function() {
new SpectrumWindowDialog( spectrumDiagram, tandem.createTandem( 'spectrumWindowDialog' ) ).show();
if ( !dialog ) {
dialog = new SpectrumWindowDialog( spectrumDiagram, tandem.createTandem( 'spectrumWindowDialog' ) );
}
dialog.show();
},
tandem: tandem.createTandem( 'showLightSpectrumButton' )
} );
Expand Down
4 changes: 1 addition & 3 deletions js/moleculesandlight/view/SpectrumWindowDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ define( function( require ) {
else {
// hide the dialog
Dialog.prototype.hide.call( self );

self.dispose();
}
};
this.shownProperty.lazyLink( shownListener );
Expand Down Expand Up @@ -109,7 +107,7 @@ define( function( require ) {
*/
dispose: function() {
this.disposeSpectrumWindowDialog();
Dialog.prototype.dispose && Dialog.prototype.dispose.call( this );
Dialog.prototype.dispose.call( this );
}
} );

Expand Down

0 comments on commit 1a65f19

Please sign in to comment.