Closed Nancy-Salpepi closed 1 year ago
Good catch. This problem was introduced in https://github.com/phetsims/calculus-grapher/commit/ff903f8238002dffe7764bb8ab46e98355947bcc for https://github.com/phetsims/calculus-grapher/issues/299, which was reported during dev testing.
In TransformedCurve, erase
does not clear the undo stack.
Proposed fix:
Add this to CurvePoint.ts (and it should be used in reset
):
public clearUndoStack() {
this.undoStack.length = 0;
}
Then in TransformedCurve.ts:
public erase(): void {
- // Set the point values to zero and smooth type.
+ // Set the curve to y = 0, and clear the undo stack.
this.points.forEach( point => {
point.y = 0;
point.pointType = 'smooth';
+ point.clearUndoStack();
} );
// Signal that this Curve has changed.
this.curveChangedEmitter.emit();
}
We should also be certain that "erase" is not an action that one can "undo". Because another way to approach this would be to save the curve before doing the erase, so that the erase can be undone. In which case the only change needed is:
public erase(): void {
+ this.save();
DIscussed with @pixelzoom, that it would be nice to consider erase as simply another operation. Just as smooth can be undo, the erase button could be undoable as well. So that the second option is preferable.
After checking, I found that the flash simulation was capable of undoing the eraser operation.
In the above commits (master and 1.0), erase is treated the same as any other operation, and can be undone. @amanda-phet FYI.
@Nancy-Salpepi Could you please have a look in master, and report back on whether this makes sense to you? If it does, please change the status of this issue to "fixed-awaiting-deploy", and unassign yourself.
I like this change a lot and it is working nicely in master.
To verify in the next RC:
Start the PhET brand sim.
In essence, the erase is simply another operation. Just as the functionality of the smooth button can be undo, the erase button is undoable as well.
Also Check that the reset all button truly resets the curve, that is that pressing the undo button after a reset all is a no-op operation.
This looks good in rc.2 Closing
Test device MacBook Air (and Dell) Operating System macOS 13.2.1 (and Win10)
Browser safari, chrome and FF
Problem description For https://github.com/phetsims/qa/issues/924, it is possible to "undo" after pressing the Erase button. This was not possible in dev.25.
Steps to reproduce
NOTE: If you only make one hill instead of 2, press the Erase button and then press the Undo button--it looks like the Undo button is working correctly because you don't see anything happen (but it has actually undone that last action of making the hill).
Visuals
https://user-images.githubusercontent.com/87318828/229852151-a59ffa5a-5266-4512-a123-12835e807c63.mp4