Skip to content

[Image] | (CX) | Handle null width/height in image editor#3583

Merged
nishasy merged 3 commits intomainfrom
image-handle-null
May 6, 2026
Merged

[Image] | (CX) | Handle null width/height in image editor#3583
nishasy merged 3 commits intomainfrom
image-handle-null

Conversation

@nishasy
Copy link
Copy Markdown
Contributor

@nishasy nishasy commented May 6, 2026

Summary:

There was a crash that happened due to a divide by zero error when the
width or height was zero.

Adding a check for that.

I also disabled the scale fields for images with invalid size, along
with a warning encouraging pressing the recalculate button.

Issue: https://khanacademy.atlassian.net/browse/LEMS-4080

Test plan:

pnpm jest packages/perseus-editor/src/widgets/image-editor/components/image-scale-input.tsx

Storybook

  • /?path=/story/widgets-image-editor-demo--image-with-empty-size-with-scale-flag

Screenshots & demo

Before After
Screenshot 2026-05-05 at 6 37 16 PM Screenshot 2026-05-05 at 6 40 07 PM
Screen.Recording.2026-05-05.at.6.40.30.PM.mov

nishasy added 2 commits May 5, 2026 18:47
…e editor

There was a crash that happened due to a divide by zero error when the
width or height was zero.

Adding a check for that.

I also disabled the scale fields for images with invalid size, along
with a warning encouraging pressing the recalculate button.

Issue: https://khanacademy.atlassian.net/browse/LEMS-4080

Test plan:
`pnpm jest packages/perseus-editor/src/widgets/image-editor/components/image-scale-input.tsx`

Storybook
- `/?path=/story/widgets-image-editor-demo--image-with-empty-size-with-scale-flag`
@nishasy nishasy self-assigned this May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🗄️ Schema Change: No Changes ✅

@nishasy nishasy requested review from a team, benchristel and catandthemachines May 6, 2026 01:51
@nishasy nishasy marked this pull request as ready for review May 6, 2026 01:51
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

npm Snapshot: Published

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

Example:

pnpm add @khanacademy/perseus@PR3583

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3583

If you are working in Khan Academy's webapp, you can run the below command.

./dev/tools/bump_perseus_version.js -t PR3583

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🛠️ Item Splitting: No Changes ✅

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Size Change: +119 B (+0.02%)

Total Size: 504 kB

📦 View Changed
Filename Size Change
packages/perseus-editor/dist/es/index.js 104 kB +119 B (+0.11%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.6 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 6.32 kB
packages/math-input/dist/es/index.js 98.5 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 12 kB
packages/perseus-core/dist/es/index.js 25.5 kB
packages/perseus-linter/dist/es/index.js 9.41 kB
packages/perseus-score/dist/es/index.js 9.78 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/index.js 198 kB
packages/perseus/dist/es/strings.js 8.5 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action

Copy link
Copy Markdown
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.

LGTM! I left one question inline.

EDIT: okay, my inline comment apparently didn't post, because "An internal error occurred, please try again.." I was wondering if we should also validate that width and height are positive and real, i.e. not NaN or Infinity.

@catandthemachines
Copy link
Copy Markdown
Member

LGTM! I left one question inline.

EDIT: okay, my inline comment apparently didn't post, because "An internal error occurred, please try again.." I was wondering if we should also validate that width and height are positive and real, i.e. not NaN or Infinity.

If you're able to add this @nishasy , I think it's worth while to future proof it.

Copy link
Copy Markdown
Member

@catandthemachines catandthemachines left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Copy Markdown
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.

LGTM!

@nishasy nishasy merged commit e6e297c into main May 6, 2026
13 of 15 checks passed
@nishasy nishasy deleted the image-handle-null branch May 6, 2026 21:36
handeyeco pushed a commit that referenced this pull request May 7, 2026
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/perseus@77.5.0

### Minor Changes

- [#3597](#3597)
[`a51b5358a0`](a51b535)
Thanks [@handeyeco](https://github.com/handeyeco)! - Deprecate
excludeDenylistKeys and add workaround for `graded`

### Patch Changes

- [#3593](#3593)
[`7dd1ff6114`](7dd1ff6)
Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Fix
blue line on vector when graph becomes interactive after correct answer


- [#3546](#3546)
[`651efcc50b`](651efcc)
Thanks [@nishasy](https://github.com/nishasy)! - Add new lint rule to
avoid using `as` and suppress lint errors for existing instances of `as`


- [#3584](#3584)
[`e5e24fb670`](e5e24fb)
Thanks [@catandthemachines](https://github.com/catandthemachines)! -
Improving screen reader experience for pause/play button on image gifs.

- Updated dependencies
\[[`651efcc50b`](651efcc),
[`51dd982ad9`](51dd982)]:
    -   @khanacademy/kas@2.2.3
    -   @khanacademy/math-input@26.4.20
    -   @khanacademy/perseus-core@26.0.3
    -   @khanacademy/perseus-linter@5.0.3
    -   @khanacademy/perseus-score@8.8.2
    -   @khanacademy/pure-markdown@2.2.8
    -   @khanacademy/simple-markdown@2.2.3
    -   @khanacademy/keypad-context@3.2.48
    -   @khanacademy/kmath@2.4.6

## @khanacademy/kas@2.2.3

### Patch Changes

- [#3546](#3546)
[`651efcc50b`](651efcc)
Thanks [@nishasy](https://github.com/nishasy)! - Add new lint rule to
avoid using `as` and suppress lint errors for existing instances of `as`

## @khanacademy/keypad-context@3.2.48

### Patch Changes

- Updated dependencies
\[[`651efcc50b`](651efcc),
[`51dd982ad9`](51dd982)]:
    -   @khanacademy/perseus-core@26.0.3

## @khanacademy/kmath@2.4.6

### Patch Changes

- Updated dependencies
\[[`651efcc50b`](651efcc),
[`51dd982ad9`](51dd982)]:
    -   @khanacademy/perseus-core@26.0.3

## @khanacademy/math-input@26.4.20

### Patch Changes

- [#3546](#3546)
[`651efcc50b`](651efcc)
Thanks [@nishasy](https://github.com/nishasy)! - Add new lint rule to
avoid using `as` and suppress lint errors for existing instances of `as`

- Updated dependencies
\[[`651efcc50b`](651efcc),
[`51dd982ad9`](51dd982)]:
    -   @khanacademy/perseus-core@26.0.3
    -   @khanacademy/keypad-context@3.2.48

## @khanacademy/perseus-core@26.0.3

### Patch Changes

- [#3546](#3546)
[`651efcc50b`](651efcc)
Thanks [@nishasy](https://github.com/nishasy)! - Add new lint rule to
avoid using `as` and suppress lint errors for existing instances of `as`


- [#3570](#3570)
[`51dd982ad9`](51dd982)
Thanks [@benchristel](https://github.com/benchristel)! - The Perseus
parsers now guard against NaN and Infinity values in number fields.
These values get converted to null by `JSON.stringify`, and previously
caused the parsers to be non-idempotent.

- Updated dependencies
\[[`651efcc50b`](651efcc)]:
    -   @khanacademy/kas@2.2.3
    -   @khanacademy/pure-markdown@2.2.8

## @khanacademy/perseus-editor@31.2.2

### Patch Changes

- [#3546](#3546)
[`651efcc50b`](651efcc)
Thanks [@nishasy](https://github.com/nishasy)! - Add new lint rule to
avoid using `as` and suppress lint errors for existing instances of `as`


- [#3583](#3583)
[`e6e297c793`](e6e297c)
Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (CX) | Handle
null width/height in image editor


- [#3597](#3597)
[`a51b5358a0`](a51b535)
Thanks [@handeyeco](https://github.com/handeyeco)! - Deprecate
excludeDenylistKeys and add workaround for `graded`

- Updated dependencies
\[[`7dd1ff6114`](7dd1ff6),
[`651efcc50b`](651efcc),
[`e5e24fb670`](e5e24fb),
[`a51b5358a0`](a51b535),
[`51dd982ad9`](51dd982)]:
    -   @khanacademy/perseus@77.5.0
    -   @khanacademy/kas@2.2.3
    -   @khanacademy/math-input@26.4.20
    -   @khanacademy/perseus-core@26.0.3
    -   @khanacademy/perseus-linter@5.0.3
    -   @khanacademy/perseus-score@8.8.2
    -   @khanacademy/keypad-context@3.2.48
    -   @khanacademy/kmath@2.4.6

## @khanacademy/perseus-linter@5.0.3

### Patch Changes

- [#3546](#3546)
[`651efcc50b`](651efcc)
Thanks [@nishasy](https://github.com/nishasy)! - Add new lint rule to
avoid using `as` and suppress lint errors for existing instances of `as`

- Updated dependencies
\[[`651efcc50b`](651efcc),
[`51dd982ad9`](51dd982)]:
    -   @khanacademy/kas@2.2.3
    -   @khanacademy/perseus-core@26.0.3
    -   @khanacademy/pure-markdown@2.2.8
    -   @khanacademy/kmath@2.4.6

## @khanacademy/perseus-score@8.8.2

### Patch Changes

- [#3546](#3546)
[`651efcc50b`](651efcc)
Thanks [@nishasy](https://github.com/nishasy)! - Add new lint rule to
avoid using `as` and suppress lint errors for existing instances of `as`

- Updated dependencies
\[[`651efcc50b`](651efcc),
[`51dd982ad9`](51dd982)]:
    -   @khanacademy/kas@2.2.3
    -   @khanacademy/perseus-core@26.0.3
    -   @khanacademy/kmath@2.4.6

## @khanacademy/pure-markdown@2.2.8

### Patch Changes

- [#3546](#3546)
[`651efcc50b`](651efcc)
Thanks [@nishasy](https://github.com/nishasy)! - Add new lint rule to
avoid using `as` and suppress lint errors for existing instances of `as`

- Updated dependencies
\[[`651efcc50b`](651efcc)]:
    -   @khanacademy/simple-markdown@2.2.3

## @khanacademy/simple-markdown@2.2.3

### Patch Changes

- [#3546](#3546)
[`651efcc50b`](651efcc)
Thanks [@nishasy](https://github.com/nishasy)! - Add new lint rule to
avoid using `as` and suppress lint errors for existing instances of `as`

Co-authored-by: github-actions[bot] <41898282+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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants