Skip to content
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

Reimplement mafsStateToInteractiveGraph #1664

Merged
merged 3 commits into from
Sep 27, 2024
Merged

Conversation

benchristel
Copy link
Member

@benchristel benchristel commented Sep 24, 2024

This change was previously implemented in PR #1654, then reverted in #1663 due
to a bug. This PR reimplements the change without the bug. The original PR
summary follows.


Previously, we were passing the entire Mafs graph state to onChange. Since
the onChange callback data is used by the Interactive Graph widget editor to
set the correct answer for the graph, a bunch of extra data like
"hasBeenInteractedWith": true was getting saved in the correct field of
the Widget data.

This extra data is not used, so its presence in datastore is potentially
confusing to future maintainers trying to understand the data. It might
also cause bugs in the future - e.g. if some code merges it into another
object in which those properties are meaningful.

This PR ensures that we only save relevant data in the correct field of
interactive graph widgets.

Issue: none

Test plan:

yarn dev; open http://localhost:5173

Play around with the graphs on the dev UI gallery page. In particular:

  • Unlimited point
  • Polygons with angle and side labels
  • Polygons with side snapping

You should not observe any issues.

Edit, save and publish an interactive graph widget in an exercise. As a
learner, you should be able to complete the exercise successfully.

@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/eleven-elephants-trade.md, packages/perseus/src/types.ts, packages/perseus/src/widgets/interactive-graph.tsx, packages/perseus/src/widgets/interactive-graphs/mafs-state-to-interactive-graph.test.ts, packages/perseus/src/widgets/interactive-graphs/mafs-state-to-interactive-graph.ts, packages/perseus/src/widgets/interactive-graphs/stateful-mafs-graph.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Copy link
Contributor

github-actions bot commented Sep 24, 2024

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (21fc055) and published it to npm. You
can install it using the tag PR1664.

Example:

yarn add @khanacademy/perseus@PR1664

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR1664

Copy link
Contributor

github-actions bot commented Sep 24, 2024

Size Change: +359 B (+0.04%)

Total Size: 863 kB

Filename Size Change
packages/perseus/dist/es/index.js 418 kB +359 B (+0.09%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 38.3 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 4.27 kB
packages/math-input/dist/es/index.js 78 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 1.48 kB
packages/perseus-editor/dist/es/index.js 279 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/perseus/dist/es/strings.js 3.4 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.4 kB

compressed-size-action

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.07%. Comparing base (1642ad9) to head (1b238b8).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1664      +/-   ##
==========================================
+ Coverage   70.87%   71.07%   +0.19%     
==========================================
  Files         561      588      +27     
  Lines      108250   112800    +4550     
  Branches     7979    12076    +4097     
==========================================
+ Hits        76727    80170    +3443     
- Misses      31401    32630    +1229     
+ Partials      122        0     -122     

Impacted file tree graph

see 1149 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1642ad9...1b238b8. Read the comment docs.

Copy link
Collaborator

@jeremywiebe jeremywiebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me.

@@ -1656,7 +1656,6 @@ class LegacyInteractiveGraph extends React.Component<Props, State> {

$(this.angle).on("move", () => {
this.onChange({
// @ts-expect-error Type '{ coords: any; type: "angle"; showAngles?: boolean | undefined; allowReflexAngles?: boolean | undefined; angleOffsetDeg?: number | undefined; snapDegrees?: number | undefined; match?: "congruent" | undefined; }' is not assignable to type 'InteractiveGraphState | undefined'.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, removing this is a sign that things are moving in the right direction! :)

@benchristel benchristel merged commit c41e4b2 into main Sep 27, 2024
9 checks passed
@benchristel benchristel deleted the benc/fix-onChange-take-2 branch September 27, 2024 22:15
benchristel pushed a commit that referenced this pull request Oct 1, 2024
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

-   [#1687](#1687) [`c0cbb484a`](c0cbb48) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Locked function aria labels (graph + editor)


-   [#1690](#1690) [`a65da60c2`](a65da60) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Add/edit/delete locked polygon labels


-   [#1683](#1683) [`2d7cadaf0`](2d7cada) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Implement locked line aria label behavior on graph


-   [#1691](#1691) [`fc16bc77f`](fc16bc7) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Locked polygon aria labels (graph + editor)


-   [#1677](#1677) [`3c73f4aa4`](3c73f4a) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Implement locked point aria label behavior on graph


-   [#1684](#1684) [`17ebfc0de`](17ebfc0) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Locked line aria label editor UI


-   [#1685](#1685) [`b3de0d80e`](b3de0d8) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Implement locked vector aria labels (graph + editor)


-   [#1689](#1689) [`eda436f00`](eda436f) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] View locked polygon labels


-   [#1682](#1682) [`039e0a360`](039e0a3) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Locked point aria label editor UI


-   [#1686](#1686) [`8230d96ee`](8230d96) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Implement locked ellipse aria labels (graph + editor)

### Patch Changes

-   [#1702](#1702) [`30725ec88`](30725ec) Thanks [@handeyeco](https://github.com/handeyeco)! - Split out validation logic for NumberLine


-   [#1671](#1671) [`f326139ee`](f326139) Thanks [@handeyeco](https://github.com/handeyeco)! - Move and test Grapher's validator


-   [#1704](#1704) [`82e0ebd71`](82e0ebd) Thanks [@handeyeco](https://github.com/handeyeco)! - Split out validation logic from table


-   [#1664](#1664) [`c41e4b2f3`](c41e4b2) Thanks [@benchristel](https://github.com/benchristel)! - Omit unused data from interactive graph onChange callback


-   [#1678](#1678) [`49efaaff5`](49efaaf) Thanks [@handeyeco](https://github.com/handeyeco)! - Port some tests to new custom matcher


-   [#1676](#1676) [`f5af24371`](f5af243) Thanks [@benchristel](https://github.com/benchristel)! - Internal: remove dead code from InteractiveGraph.validate()


-   [#1698](#1698) [`339a6db38`](339a6db) Thanks [@handeyeco](https://github.com/handeyeco)! - Refine Expression's Rubric type


-   [#1700](#1700) [`493715e3d`](493715e) Thanks [@handeyeco](https://github.com/handeyeco)! - Split out InteractiveGraph validator


-   [#1705](#1705) [`e432666fd`](e432666) Thanks [@Myranae](https://github.com/Myranae)! - Move validation logic out of the iframe widget and add tests


-   [#1693](#1693) [`466d010c6`](466d010) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Add color select to locked figure labels settings


-   [#1707](#1707) [`d3767f720`](d3767f7) Thanks [@handeyeco](https://github.com/handeyeco)! - Split out matcherValidator from Matcher


-   [#1670](#1670) [`463755970`](4637559) Thanks [@handeyeco](https://github.com/handeyeco)! - Split validation logic out of Matrix


-   [#1688](#1688) [`10ce86925`](10ce869) Thanks [@Myranae](https://github.com/Myranae)! - Move validation logic out of the cs-program widget and add tests


-   [#1703](#1703) [`e818b0f15`](e818b0f) Thanks [@handeyeco](https://github.com/handeyeco)! - Split out Plotter validator

## @khanacademy/[email protected]

### Minor Changes

-   [#1687](#1687) [`c0cbb484a`](c0cbb48) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Locked function aria labels (graph + editor)


-   [#1690](#1690) [`a65da60c2`](a65da60) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Add/edit/delete locked polygon labels


-   [#1683](#1683) [`2d7cadaf0`](2d7cada) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Implement locked line aria label behavior on graph


-   [#1691](#1691) [`fc16bc77f`](fc16bc7) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Locked polygon aria labels (graph + editor)


-   [#1677](#1677) [`3c73f4aa4`](3c73f4a) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Implement locked point aria label behavior on graph


-   [#1684](#1684) [`17ebfc0de`](17ebfc0) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Locked line aria label editor UI


-   [#1685](#1685) [`b3de0d80e`](b3de0d8) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Implement locked vector aria labels (graph + editor)


-   [#1689](#1689) [`eda436f00`](eda436f) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] View locked polygon labels


-   [#1682](#1682) [`039e0a360`](039e0a3) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Locked point aria label editor UI


-   [#1686](#1686) [`8230d96ee`](8230d96) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Aria] Implement locked ellipse aria labels (graph + editor)

### Patch Changes

-   [#1706](#1706) [`624be8143`](624be81) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figures Aria] Use TextArea instead of TextField in the locked figures aria settings


-   [#1693](#1693) [`466d010c6`](466d010) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Add color select to locked figure labels settings

-   Updated dependencies \[[`30725ec88`](30725ec), [`c0cbb484a`](c0cbb48), [`f326139ee`](f326139), [`a65da60c2`](a65da60), [`82e0ebd71`](82e0ebd), [`c41e4b2f3`](c41e4b2), [`2d7cadaf0`](2d7cada), [`49efaaff5`](49efaaf), [`fc16bc77f`](fc16bc7), [`f5af24371`](f5af243), [`339a6db38`](339a6db), [`3c73f4aa4`](3c73f4a), [`17ebfc0de`](17ebfc0), [`493715e3d`](493715e), [`e432666fd`](e432666), [`466d010c6`](466d010), [`b3de0d80e`](b3de0d8), [`eda436f00`](eda436f), [`d3767f720`](d3767f7), [`463755970`](4637559), [`10ce86925`](10ce869), [`039e0a360`](039e0a3), [`8230d96ee`](8230d96), [`e818b0f15`](e818b0f)]:
    -   @khanacademy/[email protected]

Author: khan-actions-bot

Reviewers: benchristel

Required Reviewers:

Approved By: benchristel

Checks: ⏭️  Publish npm snapshot, ✅ Cypress (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), ✅ gerald

Pull Request URL: #1680
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants