Closed KatieWoe closed 2 years ago
Reproduced in master with my working copy, using URL:
http://localhost:8080/ph-scale/ph-scale_en.html?brand=phet&ea&debugger
This is specific to the My Solution screen. To reproduce:
There have been no changes to this sim, so it's likely a regression in common code.
This is due to recent changes in ScientificNotationNode.ts for https://github.com/phetsims/scenery-phet/issues/747. The relevant code is in GrabDragListener, which uses ScientificNotationNode.toScientificNotation
.
Bisecting commits to ScientificNotationNode.ts reveals that the problem was introduced in https://github.com/phetsims/scenery-phet/commit/5a032253.
Setting a debugger in GrabDragListener drag
function reveals that the sign of the exponent is incorrect. (Note that the mantissa rounding was incorrect prior to the change.)
When dragging the OH- graph indicator ...
BEFORE https://github.com/phetsims/scenery-phet/commit/5a032253:
> value
1.0484477197064377e-7
> scientificNotation
{mantissa: '1.1', exponent: '-7'}
AFTER https://github.com/phetsims/scenery-phet/commit/5a032253:
> value
11.011688753818261e-7
> scientificNotation
{mantissa: '1.0', exponent: '7'}
Here's a failing unit test for ScientificNotationNode.js:
assert.deepEqual( ScientificNotationNode.toScientificNotation( 1.0484477197064377e-7, {
exponent: NULL_EXPONENT,
mantissaDecimalPlaces: 1
} ), { mantissa: '1.0', exponent: '-7' } );
In toScientificNotationNode
, string parsing was incorrectly stripping the sign off of negative exponents. The sign should only be stripped off of positive exponents. Fixed in the above commit. I'll leave this open until I've verified that CT is happy.
CT is happy. Closing.
The issue in CT is fairly long. Here is a part: