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] Polygon side snapping is keyboard accessible. #2270

Merged
merged 27 commits into from
Mar 4, 2025

Conversation

catandthemachines
Copy link
Member

@catandthemachines catandthemachines commented Feb 25, 2025

Summary:

Updating Polygon interactive graph implementation to have keyboard accessible side snapping. This is done by hooking up the side snapping behavior into a constraint function to make to keyboard arrow keys.

Issue: LEMS-2243

Test plan:

  • Go to: /?path=/story/perseuseditor-widgets-interactive-graph--interactive-graph-polygon
  • Set Snap to: to side measures
  • Use your keyboard (tab and arrow keys) to move the various polygon points.
  • Notice they now move!

@catandthemachines catandthemachines self-assigned this Feb 25, 2025
Copy link
Contributor

github-actions bot commented Feb 25, 2025

Size Change: +1.41 kB (+0.16%)

Total Size: 874 kB

Filename Size Change
packages/perseus/dist/es/index.js 369 kB +1.41 kB (+0.38%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39.7 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 11.1 kB
packages/math-input/dist/es/index.js 78.2 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 29.9 kB
packages/perseus-editor/dist/es/index.js 276 kB
packages/perseus-linter/dist/es/index.js 22.8 kB
packages/perseus-score/dist/es/index.js 20.6 kB
packages/perseus/dist/es/strings.js 6.74 kB
packages/pure-markdown/dist/es/index.js 4.14 kB
packages/simple-markdown/dist/es/index.js 13.1 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Feb 25, 2025

npm Snapshot: Published

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

Example:

pnpm add @khanacademy/perseus@PR2270

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

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

@nishasy
Copy link
Contributor

nishasy commented Feb 27, 2025

Question: I see this is allowing approximate sides too. Is that intended?

image

@catandthemachines
Copy link
Member Author

Question: I see this is allowing approximate sides too. Is that intended?

image

Yes, this is how the functionality works currently. It will show that when it's not exactly a whole number, but it's very close.

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 looks good overall! Thanks for this huge accessibility improvement!

Requesting changes because coords is being mutated in the reducer; we should make a copy instead. I left a few other suggestions inline too.

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.

Thanks for the updates! LGTM!

I left a couple small questions and suggestions inline, but nothing blocking.

@@ -302,7 +302,7 @@ export const polygonWithFourSidesSnappingQuestion: PerseusRenderer =
.withGridStep(0.5, 0.5)
.withSnapStep(0.25, 0.25)
.withTickStep(0.5, 0.5)
.withMarkings("none")
.withMarkings("graph")
Copy link
Member

Choose a reason for hiding this comment

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

Why did these values change? In general, I think we should be pretty cautious about changing existing values in these testdata files, since they are shared between tests and any changes could cause tests to pass for the wrong reason.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh okay, I can revert them. I updated them because I found debugging very challenging for these testdata examples and I'm curious why we don't want it to have any markings?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I believe I added "none" markings when I migrated over old data to use the builder. This data was probably originally taken from an existing question, dumped in the testdata, and never changed. And then I did a 1:1 update to the builder.

As far as use of this testdata goes, I don't think these are being used to test markings anywhere. I support removing the withMarkings call altogether for any of them that say "none"

Copy link
Member Author

Choose a reason for hiding this comment

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

Yay! I'll add them back in a follow-up PR.

Copy link
Contributor

@nishasy nishasy left a comment

Choose a reason for hiding this comment

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

LGTM! Just left one small suggestion, but this looks great.

@catandthemachines catandthemachines merged commit 941343e into main Mar 4, 2025
8 checks passed
@catandthemachines catandthemachines deleted the catjohnson/lems-2243 branch March 4, 2025 22:47
handeyeco pushed a commit that referenced this pull request Mar 5, 2025
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/math-input@23.0.0

### Major Changes

- [#2226](#2226)
[`909148cdc`](909148c)
Thanks [@handeyeco](https://github.com/handeyeco)! - Answerless
Expression: Expression can render and is interactive with answerless
data

### Patch Changes

- Updated dependencies
\[[`a0aee41b6`](a0aee41),
[`909148cdc`](909148c)]:
    -   @khanacademy/perseus-core@5.0.0
    -   @khanacademy/keypad-context@1.1.1

## @khanacademy/perseus@56.0.0

### Major Changes

- [#2233](#2233)
[`a0aee41b6`](a0aee41)
Thanks [@handeyeco](https://github.com/handeyeco)! - RadioWidget v2 in
support of answerless Radio

### Patch Changes

- [#2279](#2279)
[`e02cc4109`](e02cc41)
Thanks [@nishasy](https://github.com/nishasy)! - [SR] Tweak strings for
Segment and Angle graphs


- [#2270](#2270)
[`941343ee3`](941343e)
Thanks [@catandthemachines](https://github.com/catandthemachines)! -
Fixing side snapping within polygons to be keyboard accessible.


- [#2226](#2226)
[`909148cdc`](909148c)
Thanks [@handeyeco](https://github.com/handeyeco)! - Answerless
Expression: Expression can render and is interactive with answerless
data

- Updated dependencies
\[[`a0aee41b6`](a0aee41),
[`909148cdc`](909148c)]:
    -   @khanacademy/perseus-core@5.0.0
    -   @khanacademy/math-input@23.0.0
    -   @khanacademy/keypad-context@1.1.1
    -   @khanacademy/kmath@0.4.1
    -   @khanacademy/perseus-linter@1.3.1
    -   @khanacademy/perseus-score@2.3.1

## @khanacademy/perseus-core@5.0.0

### Major Changes

- [#2233](#2233)
[`a0aee41b6`](a0aee41)
Thanks [@handeyeco](https://github.com/handeyeco)! - RadioWidget v2 in
support of answerless Radio


- [#2226](#2226)
[`909148cdc`](909148c)
Thanks [@handeyeco](https://github.com/handeyeco)! - Answerless
Expression: Expression can render and is interactive with answerless
data

## @khanacademy/perseus-editor@17.9.0

### Minor Changes

- [#2226](#2226)
[`909148cdc`](909148c)
Thanks [@handeyeco](https://github.com/handeyeco)! - Answerless
Expression: Expression can render and is interactive with answerless
data

### Patch Changes

- [#2233](#2233)
[`a0aee41b6`](a0aee41)
Thanks [@handeyeco](https://github.com/handeyeco)! - RadioWidget v2 in
support of answerless Radio

- Updated dependencies
\[[`e02cc4109`](e02cc41),
[`941343ee3`](941343e),
[`a0aee41b6`](a0aee41),
[`909148cdc`](909148c)]:
    -   @khanacademy/perseus@56.0.0
    -   @khanacademy/perseus-core@5.0.0
    -   @khanacademy/math-input@23.0.0
    -   @khanacademy/keypad-context@1.1.1
    -   @khanacademy/kmath@0.4.1
    -   @khanacademy/perseus-linter@1.3.1
    -   @khanacademy/perseus-score@2.3.1

## @khanacademy/keypad-context@1.1.1

### Patch Changes

- Updated dependencies
\[[`a0aee41b6`](a0aee41),
[`909148cdc`](909148c)]:
    -   @khanacademy/perseus-core@5.0.0

## @khanacademy/kmath@0.4.1

### Patch Changes

- Updated dependencies
\[[`a0aee41b6`](a0aee41),
[`909148cdc`](909148c)]:
    -   @khanacademy/perseus-core@5.0.0

## @khanacademy/perseus-linter@1.3.1

### Patch Changes

- Updated dependencies
\[[`a0aee41b6`](a0aee41),
[`909148cdc`](909148c)]:
    -   @khanacademy/perseus-core@5.0.0

## @khanacademy/perseus-score@2.3.1

### Patch Changes

- Updated dependencies
\[[`a0aee41b6`](a0aee41),
[`909148cdc`](909148c)]:
    -   @khanacademy/perseus-core@5.0.0
    -   @khanacademy/kmath@0.4.1

## @khanacademy/perseus-dev-ui@5.3.1

### Patch Changes

- Updated dependencies
\[[`a0aee41b6`](a0aee41),
[`909148cdc`](909148c)]:
    -   @khanacademy/perseus-core@5.0.0
    -   @khanacademy/math-input@23.0.0
    -   @khanacademy/kmath@0.4.1
    -   @khanacademy/perseus-linter@1.3.1

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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