diff --git a/packages/graphing-solution-set/src/container/index.jsx b/packages/graphing-solution-set/src/container/index.jsx index 86948d2c7..667a7f20b 100644 --- a/packages/graphing-solution-set/src/container/index.jsx +++ b/packages/graphing-solution-set/src/container/index.jsx @@ -50,7 +50,15 @@ class Root extends React.Component { } if (!isEqual(prevProps.marks, marks)) { - this.store.dispatch(changeMarks(marks)); + // Don't dispatch marks that have correctness (evaluate mode marks) into the undo history. + // These marks are already handled in render() via the correctnessSet path and bypass the + // Redux store entirely. Dispatching them would pollute the undo history and cause the graph + // to show the correct answer when the user presses undo after returning to gather mode. + const hasCorrectness = marks && marks.find((m) => m.correctness); + + if (!hasCorrectness) { + this.store.dispatch(changeMarks(marks)); + } } } diff --git a/packages/graphing/src/container/index.jsx b/packages/graphing/src/container/index.jsx index a638467c7..edd647a05 100644 --- a/packages/graphing/src/container/index.jsx +++ b/packages/graphing/src/container/index.jsx @@ -50,7 +50,15 @@ class Root extends React.Component { } if (!isEqual(prevProps.marks, marks)) { - this.store.dispatch(changeMarks(marks)); + // Don't dispatch marks that have correctness (evaluate mode marks) into the undo history. + // These marks are already handled in render() via the correctnessSet path and bypass the + // Redux store entirely. Dispatching them would pollute the undo history and cause the graph + // to show the correct answer when the user presses undo after returning to gather mode. + const hasCorrectness = marks && marks.find((m) => m.correctness); + + if (!hasCorrectness) { + this.store.dispatch(changeMarks(marks)); + } } }