Skip to content

[Image] | (UX) | Stop large portrait images from overflowing in zoom view#3439

Merged
nishasy merged 3 commits intomainfrom
zoom-image-overflow
Apr 1, 2026
Merged

[Image] | (UX) | Stop large portrait images from overflowing in zoom view#3439
nishasy merged 3 commits intomainfrom
zoom-image-overflow

Conversation

@nishasy
Copy link
Copy Markdown
Contributor

@nishasy nishasy commented Mar 31, 2026

Summary:

After removing the explicit dimension calculations for the zoom view,
large portrait images started overlfowing and causing the zoom modal
to have a scroll bar.

Bringing the calculations back here, while still implementing the scale
feature that was added since the calculations were previously removed.

See non-broken prod code for reference.

Issue: none

Test plan:

See regression stories in the checks below.

Storybook:

  • /?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-large-portrait-image
  • /?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-large-image
  • /?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-state
  • /?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-with-graphie-image
  • /?path=/story/widgets-image-widget-demo--image-with-scaled-sizes
Before After
Screenshot 2026-03-31 at 11 24 08 AM Screenshot 2026-03-31 at 11 23 55 AM

nishasy added 2 commits March 31, 2026 11:16
…m overflowing in zoom view

After removing the explicit dimension calculations for the zoom view,
large portrait images started overlfowing and causing the zoom modal
to have a scroll bar.

Bringing the calculations back here, while still implementing the `scale`
feature that was added since the calculations were previously removed.

See [non-broken prod code](3f091b7#diff-ba490e8bdb7ae21cbdb97bb6f2ceb1853dcb0aa5dd26b0aa27ebb9c3e595c22a) for reference.

Issue: none

Test plan:
See regression stories in the checks below.

Storybook:
- `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-large-portrait-image`
- `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-large-image`
- `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-state`
- `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-with-graphie-image`
- `/?path=/story/widgets-image-widget-demo--image-with-scaled-sizes`
@nishasy nishasy self-assigned this Mar 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

🗄️ Schema Change: No Changes ✅

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

npm Snapshot: Published

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

Example:

pnpm add @khanacademy/perseus@PR3439

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

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

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

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

🛠️ Item Splitting: No Changes ✅

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

Size Change: +144 B (+0.03%)

Total Size: 495 kB

Filename Size Change
packages/perseus/dist/es/index.js 193 kB +144 B (+0.07%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.5 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 6.21 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 11.9 kB
packages/perseus-core/dist/es/index.js 25.1 kB
packages/perseus-editor/dist/es/index.js 101 kB
packages/perseus-linter/dist/es/index.js 9.3 kB
packages/perseus-score/dist/es/index.js 9.66 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/strings.js 8.09 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action

@nishasy nishasy requested a review from mark-fitzgerald March 31, 2026 18:24
@nishasy nishasy marked this pull request as ready for review March 31, 2026 18:24
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.

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.

Overall it looks good. Have a few nits and ideas, but non blocking.

alt: "Portrait image",
},
play: async ({canvas, userEvent}) => {
// eslint-disable-next-line testing-library/prefer-screen-queries
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are we ignoring this eslint error. Could you fix this implementation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe this is necessary because our repo requires all queries to be screen.getByXyz(), but the Storybook interaction tests don't use React Testing LIbrary's screen - they have their own canvas element.

Copy link
Copy Markdown
Collaborator

@jeremywiebe jeremywiebe Apr 1, 2026

Choose a reason for hiding this comment

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

This is a false positive. The linter for Testing Library sees these usages and thinks they're incorrect uses of Testing Library-related APIs, but in reality, they're Storybook APIs that just look like it.

So, it's correct to suppress these.  But, we should probably suppress it for all of our .stories.tsx files.

Adding this to our .eslintrc.js file should do the trick (note that we already have an override that includes .stories.tsx files, but we can’t add this suppression there because that override also includes .test.ts and .test.tsx files.

"overrides": [
    // ...other overrides...
    {
      "files": ["**/*.stories.@(js|jsx|ts|tsx)"],
      "rules": {
        "testing-library/prefer-screen-queries": "off"
      }
    }
  ]

? Math.max(contentScale, 2)
: Math.max(contentScale, 1);

// The scale that SvgImage will actually multiply dimensions by.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall this logic looks good to me. One question I had is have tried asking Claude if it has some ideas for optimizing the scaling code and edge cases? We have a lot of scaling all over the image widget area and it's becoming harder to track. Not something you need to fix here but a though to consider. 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think that's something I can look into as a separate investigation. I agree that it's getting confusing.

@nishasy nishasy merged commit 468910e into main Apr 1, 2026
18 of 19 checks passed
@nishasy nishasy deleted the zoom-image-overflow branch April 1, 2026 01:54
anakaren-rojas pushed a commit that referenced this pull request Apr 1, 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/[email protected]

### Patch Changes

-   [#3411](#3411) [`94ad54eb43`](94ad54e) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Align caption to image in case where image has no size


-   [#3439](#3439) [`468910ec63`](468910e) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Stop large portrait images from overflowing in zoom view


-   [#3436](#3436) [`634e65efab`](634e65e) Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - [Radio] Fix color of text in correct option choice to match specs (theme-based green)

## @khanacademy/[email protected]

### Patch Changes

-   [#3411](#3411) [`94ad54eb43`](94ad54e) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Align caption to image in case where image has no size

-   Updated dependencies \[[`94ad54eb43`](94ad54e), [`468910ec63`](468910e), [`634e65efab`](634e65e)]:
    -   @khanacademy/[email protected]

Author: khan-actions-bot

Reviewers: claude[bot], anakaren-rojas

Required Reviewers:

Approved By: anakaren-rojas

Checks: ⏭️  2 checks have been skipped, ✅ 6 checks were successful

Pull Request URL: #3437
catandthemachines pushed a commit that referenced this pull request Apr 1, 2026
…view (#3439)

## Summary:
After removing the explicit dimension calculations for the zoom view,
large portrait images started overlfowing and causing the zoom modal
to have a scroll bar.

Bringing the calculations back here, while still implementing the `scale`
feature that was added since the calculations were previously removed.

See [non-broken prod code](3f091b7#diff-ba490e8bdb7ae21cbdb97bb6f2ceb1853dcb0aa5dd26b0aa27ebb9c3e595c22a) for reference.

Issue: none

## Test plan:
See regression stories in the checks below.

Storybook:
- `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-large-portrait-image`
- `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-large-image`
- `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-state`
- `/?path=/story/widgets-image-visual-regression-tests-interactions--zoom-clicked-with-graphie-image`
- `/?path=/story/widgets-image-widget-demo--image-with-scaled-sizes`

| Before | After |
| --- | --- |
| <img width="1159" height="1042" alt="Screenshot 2026-03-31 at 11 24 08 AM" src="https://github.com/user-attachments/assets/c5a34c50-f394-4cae-b27f-83fe7bfad6b3" /> | <img width="1159" height="1045" alt="Screenshot 2026-03-31 at 11 23 55 AM" src="https://github.com/user-attachments/assets/0a75d210-9c0b-4962-9089-ba6107f55bb6" /> |

Author: nishasy

Reviewers: claude[bot], catandthemachines, nishasy, mark-fitzgerald, ivyolamit

Required Reviewers:

Approved By: catandthemachines

Checks: ✅ 10 checks were successful, ⏭️  1 check has been skipped

Pull Request URL: #3439
catandthemachines pushed a commit that referenced this pull request Apr 1, 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/[email protected]

### Patch Changes

-   [#3411](#3411) [`94ad54eb43`](94ad54e) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Align caption to image in case where image has no size


-   [#3439](#3439) [`468910ec63`](468910e) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Stop large portrait images from overflowing in zoom view


-   [#3436](#3436) [`634e65efab`](634e65e) Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - [Radio] Fix color of text in correct option choice to match specs (theme-based green)

## @khanacademy/[email protected]

### Patch Changes

-   [#3411](#3411) [`94ad54eb43`](94ad54e) Thanks [@nishasy](https://github.com/nishasy)! - [Image] | (UX) | Align caption to image in case where image has no size

-   Updated dependencies \[[`94ad54eb43`](94ad54e), [`468910ec63`](468910e), [`634e65efab`](634e65e)]:
    -   @khanacademy/[email protected]

Author: khan-actions-bot

Reviewers: claude[bot], anakaren-rojas

Required Reviewers:

Approved By: anakaren-rojas

Checks: ⏭️  2 checks have been skipped, ✅ 6 checks were successful

Pull Request URL: #3437
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