phetsims / acid-base-solutions

"Acid-Base Solutions" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/sims/html/acid-base-solutions/latest/acid-base-solutions_en.html
GNU General Public License v3.0
4 stars 7 forks source link

pH is not updating in My Solutions screen #199

Closed pixelzoom closed 1 year ago

pixelzoom commented 1 year ago

I broke something during #178 PhET-iO instrumentation. The pH value is not updating in the My Solutions screen. Investigating...

pixelzoom commented 1 year ago

The problem is in ABSModel.ts. It's updating only when the selected solution changes. It also needs to update when that solution's pH changes. Relevant code:

    this.pHProperty = new DerivedProperty( [ solutionProperty ], solution => solution.pHProperty.value, {
      tandem: tandem.createTandem( 'pHProperty' ),
      phetioValueType: NumberIO
    } );
pixelzoom commented 1 year ago

Fixed in the above commit. The new derivation in ABSModel.ts is:

    // Synchronize with the pH of the selected solution.
    this.pHProperty = DerivedProperty.deriveAny( [ solutionProperty, ...solutions.map( solution => solution.pHProperty ) ],
      () => solutionProperty.value.pHProperty.value, {
        tandem: tandem.createTandem( 'pHProperty' ),
        phetioValueType: NumberIO
      } );