From 74f482052b5331d918212dcfd847a477f1e5e2d4 Mon Sep 17 00:00:00 2001 From: Andrei Miron Date: Mon, 25 May 2026 11:45:38 +0300 Subject: [PATCH] fix(graphing): make sure evaluate mode marks are not included in undo/redo history PIE-582 --- packages/graphing-solution-set/src/container/index.jsx | 10 +++++++++- packages/graphing/src/container/index.jsx | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) 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)); + } } }