Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unbelievably bad PhET-iO support in SpectrumWindowDialog #185

Open
pixelzoom opened this issue Apr 24, 2018 · 3 comments
Open

unbelievably bad PhET-iO support in SpectrumWindowDialog #185

pixelzoom opened this issue Apr 24, 2018 · 3 comments

Comments

@pixelzoom
Copy link
Contributor

pixelzoom commented Apr 24, 2018

Noticed while working on #184 in SpectrumWindowDialog.

There's some really awful stuff in SpectrumWindowDialog, "done primarily for PhET-iO support". I can't tell who is responsible based on GitHub commits.

Here's the relevant part of the implementation:

function SpectrumWindowDialog( content, spectrumWindowButton, tandem ) {
...
    // Create a property that both signals changes to the 'shown' state and can also be used to show/hide the dialog
    // remotely.  This is done primarily for PhET-iO support.  TODO: Move into the Dialog type?
    this.shownProperty = new Property( false, {
      tandem: tandem.createTandem( 'shownProperty' ),
      phetioType: PropertyIO( BooleanIO )
    } );

    var shownListener = function( shown ) {
      if ( shown ) {
        Dialog.prototype.show.call( self );
      }
      else {
        // hide the dialog
        Dialog.prototype.hide.call( self );
      }
    };
    this.shownProperty.lazyLink( shownListener )
...
}

return inherit( Dialog, SpectrumWindowDialog, {
    hide: function() {
      this.shownProperty.value = false;
    },
    show: function() {
      this.shownProperty.value = true;
    },
    ...
} 

So many things wrong with this, but the 2 big things are:

(1) There's something being done here for PhET-iO support that is not at all specific to this dialog, and belongs in Dialog. Is it really necessary? If it's not necessary, delete it. If it's necessary, move it to Dialog so that other dialogs benefit.

(2) Overriding show and hide to do something different, then calling the supertype's show and hide in a Property listener has an anti-pattern code smell. If this is moved to Dialog, let's implement a real solution.

(CM edited.)

@jessegreenberg
Copy link
Contributor

This TODO is at least a year old and the feature hasn't been added to Dialog in that time, maybe it is no longer required.

I am not very familiar so removing my assignment, let me know if I can help.

@jessegreenberg jessegreenberg removed their assignment May 26, 2018
@samreid
Copy link
Member

samreid commented Jun 12, 2018

I'm not planning to work on this until we revisit Molecules and Light, unless it is blocking work for Dialog. @pixelzoom please reassign me if this is blocking work on Dialog.

@samreid
Copy link
Member

samreid commented Jan 2, 2019

Same problem in gene-expression-essentials/js/multiple-cells/view/FluorescentCellsPictureDialog.js

samreid added a commit to phetsims/gene-expression-essentials that referenced this issue Jan 2, 2019
samreid added a commit that referenced this issue Jan 2, 2019
jessegreenberg pushed a commit to phetsims/greenhouse-effect that referenced this issue Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants