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

[Interactive Graph] Open and Closing logic for unlimited polygon. #1852

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

catandthemachines
Copy link
Member

@catandthemachines catandthemachines commented Nov 14, 2024

Summary:

Adding opening and closing behavior to unlimited polygon including:

  • New buttons for graph controls.
  • Reducing redundancy between polygon and unlimited polygon behavior.
  • And more robust testing for unlimited graph controls.

Issue: LEMS-2570

Test plan:

@catandthemachines catandthemachines self-assigned this Nov 14, 2024
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Nov 14, 2024

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/twenty-baboons-shave.md, packages/perseus/src/strings.ts, packages/perseus/src/widgets/interactive-graphs/interactive-graph.stories.tsx, packages/perseus/src/widgets/interactive-graphs/interactive-graph.testdata.ts, packages/perseus/src/widgets/interactive-graphs/mafs-graph.test.tsx, packages/perseus/src/widgets/interactive-graphs/mafs-graph.tsx, packages/perseus/src/widgets/interactive-graphs/mafs-state-to-interactive-graph.test.ts, packages/perseus/src/widgets/interactive-graphs/types.ts, packages/perseus/src/widgets/interactive-graphs/graphs/polygon.tsx, packages/perseus/src/widgets/interactive-graphs/reducer/initialize-graph-state.ts, packages/perseus/src/widgets/interactive-graphs/reducer/interactive-graph-action.ts, packages/perseus/src/widgets/interactive-graphs/reducer/interactive-graph-reducer.test.ts, packages/perseus/src/widgets/interactive-graphs/reducer/interactive-graph-reducer.ts

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

@khan-actions-bot khan-actions-bot requested a review from a team November 14, 2024 00:07
@catandthemachines catandthemachines marked this pull request as draft November 14, 2024 00:07
Copy link
Contributor

github-actions bot commented Nov 14, 2024

Size Change: +471 B (+0.04%)

Total Size: 1.29 MB

Filename Size Change
packages/perseus/dist/es/index.js 420 kB +443 B (+0.11%)
packages/perseus/dist/es/strings.js 3.58 kB +28 B (+0.79%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 38.9 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 77.8 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 699 kB
packages/perseus-linter/dist/es/index.js 22.2 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
Contributor

github-actions bot commented Nov 14, 2024

npm Snapshot: Published

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

Example:

yarn add @khanacademy/perseus@PR1852

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

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

Copy link
Member

@benchristel benchristel left a comment

Choose a reason for hiding this comment

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

This is looking good! Thanks for backfilling tests for the other reducer actions.

I left some suggestions inline about things that I think could be refactored and simplified.

* Question: Should we always be setting the focus index to the end of the list?
* Perhaps a better solution is the next point in the coordinates,
* unless that does not exist.
* */
Copy link
Member

Choose a reason for hiding this comment

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

I think this is a question for Caitlyn.

Comment on lines 414 to 415
const shouldShowRemoveButton =
showRemovePointButton && focusedPointIndex !== null;
Copy link
Member

Choose a reason for hiding this comment

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

Since this variable now controls whether the remove button is enabled, I think it should be called shouldEnableRemoveButton. It could also incorporate closedPolygon:

Suggested change
const shouldShowRemoveButton =
showRemovePointButton && focusedPointIndex !== null;
const shouldEnableRemoveButton =
!closedPolygon && showRemovePointButton && focusedPointIndex !== null;

I wonder if state.showRemovePointButton should also be renamed to state.enableRemovePointButton. Or if a different name entirely is appropriate, since that state variable doesn't completely control whether the button is enabled or not.

I'm kind of confused about when the remove button is enabled vs. disabled, and that might be a sign that it will be confusing to learners as well.

kind="secondary"
color="destructive"
// Disable button when polygon is closed.
disabled={closedPolygon || !shouldShowRemoveButton}
Copy link
Member

Choose a reason for hiding this comment

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

Re: my comment above, maybe closedPolygon should be incorporated into shouldShowRemoveButton/shouldEnableRemoveButton so all the logic can be in one place.

@khan-actions-bot khan-actions-bot requested a review from a team November 15, 2024 22:21
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