diff --git a/.changeset/heavy-buckets-think.md b/.changeset/heavy-buckets-think.md new file mode 100644 index 0000000000..b72409a458 --- /dev/null +++ b/.changeset/heavy-buckets-think.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus-editor": patch +--- + +[Interactive Graph Editor] Remove the use of graphKey for remounting diff --git a/packages/perseus-editor/src/widgets/__tests__/interactive-graph-editor.test.tsx b/packages/perseus-editor/src/widgets/__tests__/interactive-graph-editor.test.tsx index 6aa0ac81bf..c39fcaf9e4 100644 --- a/packages/perseus-editor/src/widgets/__tests__/interactive-graph-editor.test.tsx +++ b/packages/perseus-editor/src/widgets/__tests__/interactive-graph-editor.test.tsx @@ -617,21 +617,4 @@ describe("InteractiveGraphEditor", () => { // Assert expect(ref.current?.getSaveWarnings()).toEqual([]); }); - - test("buildGraphKey returns the correct key", async () => { - // Arrange - const graph: PerseusGraphType = { - type: "polygon", - numSides: 4, - snapTo: "grid", - showAngles: true, - showSides: true, - }; - - // Act - const key = InteractiveGraphEditor.buildGraphKey(graph); - - // Assert - expect(key).toEqual("polygon:4:grid:true:true"); - }); }); diff --git a/packages/perseus-editor/src/widgets/interactive-graph-editor.tsx b/packages/perseus-editor/src/widgets/interactive-graph-editor.tsx index ef853fae6b..3648302844 100644 --- a/packages/perseus-editor/src/widgets/interactive-graph-editor.tsx +++ b/packages/perseus-editor/src/widgets/interactive-graph-editor.tsx @@ -30,7 +30,6 @@ import type { PerseusInteractiveGraphWidgetOptions, APIOptionsWithDefaults, LockedFigure, - PerseusGraphType, } from "@khanacademy/perseus"; import type {PropsFor} from "@khanacademy/wonder-blocks-core"; @@ -199,20 +198,6 @@ class InteractiveGraphEditor extends React.Component { DeprecationMixin.UNSAFE_componentWillMount.call(this); } - static buildGraphKey(correct: PerseusGraphType) { - const testGraphKey: any[] = []; - for (const key in correct) { - if (correct[key]) { - typeof correct[key] === "number" || - typeof correct[key] === "string" || - typeof correct[key] === "boolean" - ? testGraphKey.push(correct[key]) - : testGraphKey.push(0); - } - } - return testGraphKey.join(":"); - } - render() { let graph; let equationString; @@ -262,9 +247,6 @@ class InteractiveGraphEditor extends React.Component { this.props.onChange({correct: correct}); }, } as const; - // This is used to force a remount of the graph component - // when there's a significant change - const graphKey = InteractiveGraphEditor.buildGraphKey(correct); graph = ( // There are a bunch of props that renderer.jsx passes to widgets via @@ -273,7 +255,6 @@ class InteractiveGraphEditor extends React.Component { // @ts-expect-error - TS2769 - No overload matches this call.