-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Interactive Graph Editor] Add UI for updating starting coordinates (linear and ray) #1382
Conversation
Size Change: +936 B (+0.11%) Total Size: 854 kB
ℹ️ View Unchanged
|
GeraldRequired Reviewers
Don't want to be involved in this pull request? Comment |
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (a741a28) and published it to npm. You Example: yarn add @khanacademy/perseus@PR1382 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR1382 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1382 +/- ##
==========================================
+ Coverage 69.78% 71.09% +1.31%
==========================================
Files 503 508 +5
Lines 105061 105355 +294
Branches 7563 10771 +3208
==========================================
+ Hits 73315 74903 +1588
+ Misses 31630 30452 -1178
+ Partials 116 0 -116
... and 124 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
@@ -254,12 +255,18 @@ class InteractiveGraphEditor extends React.Component<Props> { | |||
let correct = this.props.correct; | |||
// @ts-expect-error - TS2532 - Object is possibly 'undefined'. | |||
if (correct.type === newProps.graph.type) { | |||
correct = _.extend({}, correct, newProps.graph); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lodash removal
this.props.onChange({ | ||
correct: correct, | ||
graph: this.props.graph, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added graph
here because it's required for the update to happen correctly.
…startCoords as a separate prop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall test coverage and implementation looks pretty clean and straight forward to me, Approved! Though highly recommend a review from a fellow interactive graph peep ;)
graph: { | ||
type: correct.type, | ||
coords: | ||
this.props.graph?.type === "circle" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very curious, why do these property need to be exposed now for the starting coordinates work? (non-blocking question 😉)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the serialization function, which is used to copy/paste the graph across editors. Before, coords
was never being used, because it was never part of the initial state. It was always undefined, and then it got set as the user would start interacting with it.
In this PR, I'm trying to set initial specific coordinates on the graph, and it needs to be copy/pastable in that state, which is why I now needed to add coords
here when it wasn't there before.
I'll add a comment here for clarity!
Just confirming, it only meant to work once in Storybook? It uses the default coordinates, but if I move it again it doesn't work to more to default. Might need to check it out. |
}; | ||
this.props.onChange({graph: graph}); | ||
}; | ||
|
||
serialize(): PerseusInteractiveGraphWidgetOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is serialize
called? GoLand's "find usages" feature isn't turning up anything. I was also able to delete serialize
and got no type errors.
Asking because there's a change to this function (below).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's used here inside _maybeCopyWidgets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also called by the save mechanism in webapp by calling serialize()
on a ref to the EditorPage
component. The call stack is essentially:
EditorPage
ItemEditor
Editor
(which is namedquestionEditor
in theItemEditor
code.
The Editor
then calls serialize
on each widget (through a ref handle).
…'t need startCoords as a separate prop" This reverts commit 16095ae. Turns out we can't use the same coords after all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @catandthemachines. LGTM!
packages/perseus-editor/src/components/__tests__/start-coord-settings.test.tsx
Outdated
Show resolved
Hide resolved
…ettings.test.tsx Co-authored-by: Jeremy Wiebe <[email protected]>
Talked about @catandthemachines's comment offline - that behavior is expected. The preview on the right is not a wysiwyg for the starting coords. When you update the starting coords, it updates the starting state and thus displays it in the preview. But that preview is still only showing the learner experience. |
…rlier PR, we don't need startCoords as a separate prop""" This reverts commit 64eb1ba. Adding back `startCoords`
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @khanacademy/[email protected] ### Minor Changes - [#1382](#1382) [`f392dcfba`](f392dcf) Thanks [@nishasy](https://github.com/nishasy)! - [Interactive Graph Editor] Implement UI to edit start coordinates for linear and ray graphs ## @khanacademy/[email protected] ### Minor Changes - [#1382](#1382) [`f392dcfba`](f392dcf) Thanks [@nishasy](https://github.com/nishasy)! - [Interactive Graph Editor] Implement UI to edit start coordinates for linear and ray graphs ### Patch Changes - Updated dependencies \[[`f392dcfba`](f392dcf)]: - @khanacademy/[email protected] Author: khan-actions-bot Reviewers: benchristel Required Reviewers: Approved By: benchristel Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage (ubuntu-latest, 20.x), ⏭️ Publish npm snapshot, ✅ Jest Coverage (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #1414
startCoords, | ||
latestPropsRef, | ||
startCoords, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nishasy Was this intentional to list startCoords
twice here? :)
Summary:
Implement a UI in the interactive graph editor to allow conten authors
to set custom starting coordinates for interactive graphs. This is a
prerequisite for hint mode.
Note: There was some funky stuff happening when I tried using
coords
.I added a
startCoords
field to the graph types, and that seemed to fixall my issues. This change is included in this PR.
Included in this PR
startCoords
fieldIssue: https://khanacademy.atlassian.net/browse/LEMS-2052
Test plan:
Storybook existing starting coords
Storybook new graph
Copy/pasting
into the hint text box
start coords